package client;

import client.anticheat.CheatTracker;
import client.inventory.*;
import client.inventory.MapleRing.RingComparator;
import constants.GameConstants;
import constants.MapConstants;
import constants.ServerConfig;
import constants.ServerConstants.PlayerGMRank;
import constants.WorldConstants;
import database.BeePool;
import gui.Start;
import gui.jyhss.jyhwpss;
import gui.进阶BOSS.Mushplotact;
import handling.cashshop.CashShopServer;
import handling.channel.ChannelServer;
import handling.login.LoginServer;
import handling.world.*;
import handling.world.World.*;
import handling.world.family.MapleFamily;
import handling.world.family.MapleFamilyBuff;
import handling.world.family.MapleFamilyBuff.MapleFamilyBuffEntry;
import handling.world.family.MapleFamilyCharacter;
import handling.world.guild.MapleGuild;
import handling.world.guild.MapleGuildCharacter;
import io.netty.channel.Channel;
import scripting.EventInstanceManager;
import scripting.EventManager;
import scripting.NPCScriptManager;
import server.*;
import server.FishingRewardFactory.FishingReward;
import server.Timer.BuffTimer;
import server.Timer.EtcTimer;
import server.Timer.EventTimer;
import server.Timer.MapTimer;
import server.life.MapleMonster;
import server.life.MobSkill;
import server.life.PlayerNPC;
import server.maps.*;
import server.movement.LifeMovementFragment;
import server.quest.MapleQuest;
import server.shops.IMaplePlayerShop;
import server.shops.MaplePlayerShopItem;
import tools.*;
import tools.data.MaplePacketLittleEndianWriter;
import tools.packet.*;

import java.awt.*;
import java.io.Serializable;
import java.lang.ref.WeakReference;
import java.sql.*;
import java.util.List;
import java.util.*;
import java.util.Map.Entry;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.ReentrantReadWriteLock;

public class MapleCharacter extends AbstractAnimatedMapleMapObject implements Serializable {
    private static long serialVersionUID = 845748950829L;
    private String name;
    private String chalktext;
    private String BlessOfFairy_Origin;
    private String charmessage;
    private String prefix;
    private String teleportname;
    private String nowmacs;
    private String loginkey;
    private String serverkey;
    private String clientkey;
    private String accountsecondPassword;
    private long lastCombo;
    private long lastfametime;
    private long keydown_skill;
    private long lastRecoveryTime;
    private long nextConsume;
    private long pqStartTime;
    private long lastHPTime;
    private long lastMPTime;
    private long lastMDTime;
    private long lastStorageTime;
    private long mapChangeTime;
    private long mrqdTime;
    private byte dojoRecord;
    private byte gmLevel;
    private byte gender;
    private byte initialSpawnPoint;
    private byte skinColor;
    private byte guildrank;
    private byte allianceRank;
    private byte world;
    private byte fairyExp;
    private byte numClones;
    private byte subcategory;
    private byte fairyHour;
    private short level;
    private short mulung_energy;
    private short availableCP;
    private short totalCP;
    private short fame;
    private short hpmpApUsed;
    private short job;
    private short remainingAp;
    private int accountid;
    private int id;
    private int meso;
    private int exp;
    private int hair;
    private int face;
    private int mapid;
    private int bookCover;
    private int dojo;
    private int guildid;
    private int fallcounter;
    private int maplepoints;
    private int chair;
    private int itemEffect;
    private int vpoints;
    private int rank;
    private int rankMove;
    private int jobRank;
    private int jobRankMove;
    private int marriageId;
    private int marriageItemId;
    private int currentrep;
    private int totalrep;
    private int linkMid;
    private int coconutteam;
    private int followid;
    private int battleshipHP;
    private int expression;
    private int constellation;
    private int blood;
    private int month;
    private int day;
    private int beans;
    private int beansNum;
    private int beansRange;
    private int gachexp;
    private int combo;
    private int MSG;
    private int 打怪;
    private int 吸怪;
    private int FLY_吸怪;
    private int vip;
    private int CsMod;
    private int skillzq;
    private Point old;
    private boolean smega;
    private boolean gashponmega;
    private boolean hidden;
    private boolean hasSummon;
    private boolean 精灵商人购买开关;
    private boolean 玩家私聊开关;
    private boolean 玩家密语开关;
    private boolean 好友聊天开关;
    private boolean 队伍聊天开关;
    private boolean 公会聊天开关;
    private boolean 联盟聊天开关;
    private boolean GM吸怪讯息开关;
    private boolean canSetBeansNum;
    private boolean Vip_Medal;
    private boolean auto吸怪;
    private boolean DebugMessage;
    private boolean itemVacs;
    private boolean mobVacs;
    private boolean beansStart;
    private int[] wishlist;
    private int[] rocks;
    private int[] savedLocations;
    private int[] regrocks;
    private int[] remainingSp;
    private int[] savedHairs;
    private int[] savedFaces;
    private transient AtomicInteger inst;
    private transient List<LifeMovementFragment> lastres;
    private List<Integer> lastmonthfameids;
    private List<MapleDoor> doors;
    private List<MaplePet> pets;
    private long limitBreak;
    private int reinNumber;
    private boolean petAutoFood;
    private MapleClient c;
    private transient WeakReference<MapleCharacter>[] clones;
    private transient Set<MapleMonster> controlled;
    private transient Set<MapleMapObject> visibleMapObjects;
    private transient ReentrantReadWriteLock visibleMapObjectsLock;
    private Map<MapleQuest, MapleQuestStatus> quests;
    private Map<Integer, String> questinfo;
    private Map<ISkill, SkillEntry> skills;
    private transient Map<MapleBuffStat, MapleBuffStatValueHolder> effects;
    private transient Map<Integer, MapleBuffStatValueHolder> skillID;
    private transient Map<Integer, MapleSummon> summons;
    private transient Map<Integer, MapleCoolDownValueHolder> coolDowns;
    private transient Map<MapleDisease, MapleDiseaseValueHolder> diseases;
    private CashShop cs;
    private transient Deque<MapleCarnivalChallenge> pendingCarnivalRequests;
    private transient MapleCarnivalParty carnivalParty;
    private BuddyList buddylist;
    private MonsterBook monsterbook;
    private transient CheatTracker anticheat;
    private transient MapleLieDetector antiMacro;
    private MapleClient client;
    private PlayerStats stats;
    private transient PlayerRandomStream CRand;
    private transient MapleMap map;
    private transient MapleShop shop;
    private transient RockPaperScissors rps;
    private MapleStorage storage;
    private transient MapleTrade trade;
    private MapleMount mount;
    private List<Integer> finishedAchievements;
    private MapleMessenger messenger;
    private byte[] petStore;
    private transient IMaplePlayerShop playerShop;
    private MapleParty party;
    private boolean invincible;
    private boolean canTalk;
    private boolean clone;
    private boolean followinitiator;
    private boolean followon;
    private MapleGuildCharacter mgc;
    private MapleFamilyCharacter mfc;
    private transient EventInstanceManager eventInstance;
    private MapleInventory[] inventory;
    private SkillMacro[] skillMacros;
    private MapleKeyLayout keylayout;
    private ItemVac ItemVac;
    private MobVac MobVac;
    public int maxLevel;
    private int 刷钱模式;
    public int maxLevel1;
    private transient ScheduledFuture<?> beholderHealingSchedule;
    private transient ScheduledFuture<?> beholderBuffSchedule;
    private transient ScheduledFuture<?> BerserkSchedule;
    private transient ScheduledFuture<?> dragonBloodSchedule;
    private transient ScheduledFuture<?> fairySchedule;
    private transient ScheduledFuture<?> mapTimeLimitTask;
    private transient ScheduledFuture<?> fishing;
    private transient Event_PyramidSubway pyramidSubway;
    private transient List<Integer> pendingExpiration;
    private transient List<Integer> pendingSkills;
    private transient Map<Integer, Integer> movedMobs;
    public long 整理背包冷却;
    public long 集合背包冷却;
    private boolean stopMoving;
    private double 套装伤害加成;
    private int clonedamgerate;
    public int jyhbh;
    private int 副本地图;
    private int schoolIntegral;


    private MapleCharacter(boolean ChannelServer) {
        this.teleportname = "";
        this.nowmacs = "";
        this.nextConsume = 0L;
        this.pqStartTime = 0L;
        this.guildrank = 5;
        this.allianceRank = 5;
        this.fairyExp = 30;
        this.fairyHour = 1;
        this.guildid = 0;
        this.fallcounter = 0;
        this.rank = 1;
        this.rankMove = 0;
        this.jobRank = 1;
        this.jobRankMove = 0;
        this.marriageItemId = 0;
        this.linkMid = 0;
        this.coconutteam = 0;
        this.followid = 0;
        this.battleshipHP = 0;
        this.MSG = 0;
        this.打怪 = 0;
        this.吸怪 = 0;
        this.FLY_吸怪 = 0;
        this.CsMod = 0;
        this.skillzq = 0;
        this.old = new Point(0, 0);
        this.smega = true;
        this.gashponmega = true;
        this.hasSummon = false;
        this.精灵商人购买开关 = false;
        this.玩家私聊开关 = false;
        this.玩家密语开关 = false;
        this.好友聊天开关 = false;
        this.队伍聊天开关 = false;
        this.公会聊天开关 = false;
        this.联盟聊天开关 = false;
        this.GM吸怪讯息开关 = false;
        this.canSetBeansNum = false;
        this.Vip_Medal = true;
        this.auto吸怪 = false;
        this.DebugMessage = false;
        this.itemVacs = false;
        this.mobVacs = false;
        this.beansStart = false;
        this.remainingSp = new int[10];
        this.savedHairs = new int[6];
        this.savedFaces = new int[6];
        this.skills = (Map<ISkill, SkillEntry>) new LinkedHashMap();
        this.effects = new ConcurrentEnumMap(MapleBuffStat.class);
        this.skillID = (Map<Integer, MapleBuffStatValueHolder>) new LinkedHashMap();
        this.coolDowns = (Map<Integer, MapleCoolDownValueHolder>) new LinkedHashMap();
        this.diseases = new ConcurrentEnumMap(MapleDisease.class);
        this.finishedAchievements = (List<Integer>) new ArrayList();
        this.invincible = false;
        this.canTalk = true;
        this.clone = false;
        this.followinitiator = false;
        this.followon = false;
        this.skillMacros = new SkillMacro[5];
        this.maxLevel = ServerConfig.maxLevel;
        this.刷钱模式 = 0;
        this.maxLevel1 = WorldConstants.maxLevel;
        this.pyramidSubway = null;
        this.pendingExpiration = null;
        this.pendingSkills = null;
        this.movedMobs = (Map<Integer, Integer>) new HashMap();
        this.整理背包冷却 = 0L;
        this.集合背包冷却 = 0L;
        this.clonedamgerate = 0;
        this.jyhbh = -1;
        this.setStance(this.副本地图 = 0);
        this.setPosition(new Point(0, 0));
        this.inventory = new MapleInventory[MapleInventoryType.values().length];
        for (MapleInventoryType type : MapleInventoryType.values()) {
            this.inventory[type.ordinal()] = new MapleInventory(type);
        }
        this.quests = new LinkedHashMap();
        this.stats = new PlayerStats(this);
        for (int i = 0; i < this.remainingSp.length; ++i) {
            this.remainingSp[i] = 0;
        }
        for (int i = 0; i < this.savedHairs.length; ++i) {
            this.savedHairs[i] = -1;
        }
        for (int i = 0; i < this.savedFaces.length; ++i) {
            this.savedFaces[i] = -1;
        }
        if (ChannelServer) {
            this.lastCombo = 0L;
            this.mulung_energy = 0;
            this.combo = 0;
            this.keydown_skill = 0L;
            this.lastHPTime = 0L;
            this.lastMPTime = 0L;
            this.mapChangeTime = 0L;
            this.lastRecoveryTime = 0L;
            this.petStore = new byte[3];
            for (int i = 0; i < this.petStore.length; ++i) {
                this.petStore[i] = -1;
            }
            this.wishlist = new int[10];
            this.rocks = new int[10];
            this.regrocks = new int[5];
            this.clones = (WeakReference<MapleCharacter>[]) new WeakReference[25];
            for (int i = 0; i < this.clones.length; ++i) {
                this.clones[i] = new WeakReference(null);
            }
            (this.inst = new AtomicInteger()).set(0);
            this.keylayout = new MapleKeyLayout();
            this.doors = new ArrayList();
            this.controlled = new LinkedHashSet();
            this.summons = new LinkedHashMap();
            this.visibleMapObjects = new LinkedHashSet();
            this.visibleMapObjectsLock = new ReentrantReadWriteLock();
            this.pendingCarnivalRequests = new LinkedList();
            this.savedLocations = new int[SavedLocationType.values().length];
            for (int i = 0; i < SavedLocationType.values().length; ++i) {
                this.savedLocations[i] = -1;
            }
            this.questinfo = new LinkedHashMap();
            this.anticheat = new CheatTracker(this);
            this.pets = new ArrayList();
        }
    }

    public static MapleCharacter getDefault(MapleClient client, int type) {
        MapleCharacter ret = new MapleCharacter(false);
        ret.client = client;
        ret.map = null;
        ret.exp = 0;
        ret.gmLevel = 0;
        ret.job = (short) ((type == 1) ? 0 : ((type == 0) ? 1000 : ((type == 3) ? 2001 : ((type == 4) ? 3000 : 2000))));
        ret.beans = 0;
        ret.meso = 0;
        ret.level = 1;
        ret.remainingAp = 0;
        ret.fame = 0;
        ret.accountid = client.getAccID();
        ret.buddylist = new BuddyList((byte) 20);
        ret.stats.str = 12;
        ret.stats.dex = 5;
        ret.stats.int_ = 4;
        ret.stats.luk = 4;
        ret.stats.maxhp = 50;
        ret.stats.hp = 50;
        ret.stats.maxmp = 50;
        ret.stats.mp = 50;
        ret.prefix = "";
        ret.gachexp = 0;
        ret.limitBreak = 199999L;
        ret.reinNumber = 0;
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = con.prepareStatement("SELECT name, 2ndpassword, mPoints,  vpoints, VIP, loginkey, serverkey, clientkey FROM accounts WHERE id = ?");
            ps.setInt(1, ret.accountid);
            try (ResultSet rs = ps.executeQuery()) {
                if (rs.next()) {
                    ret.client.setAccountName(rs.getString("name"));
                    ret.accountsecondPassword = rs.getString("2ndpassword");
                    ret.maplepoints = rs.getInt("mPoints");
                    ret.vpoints = rs.getInt("vpoints");
                    ret.vip = rs.getInt("VIP");
                    ret.loginkey = rs.getString("loginkey");
                    ret.serverkey = rs.getString("serverkey");
                    ret.clientkey = rs.getString("clientkey");
                }
            }
            ps.close();
        } catch (SQLException e) {
            System.err.println("Error getting character default" + e);
            FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) e);
        }
        return ret;
    }

    public static MapleCharacter ReconstructChr(CharacterTransfer ct, MapleClient client, boolean isChannel) {
        MapleCharacter ret = new MapleCharacter(true);
        ret.client = client;
        if (!isChannel) {
            ret.client.setChannel((int) ct.channel);
        }
        ret.nowmacs = ct.nowmacs;
        ret.canTalk = ct.canTalk;
        ret.DebugMessage = ct.DebugMessage;
        ret.auto吸怪 = ct.auto吸怪;
        ret.GM吸怪讯息开关 = ct.GM吸怪讯息开关;
        ret.Vip_Medal = ct.Vip_Medal;
        ret.精灵商人购买开关 = ct.精灵商人购买开关;
        ret.玩家私聊开关 = ct.玩家私聊开关;
        ret.玩家密语开关 = ct.玩家密语开关;
        ret.好友聊天开关 = ct.好友聊天开关;
        ret.队伍聊天开关 = ct.队伍聊天开关;
        ret.公会聊天开关 = ct.公会聊天开关;
        ret.联盟聊天开关 = ct.联盟聊天开关;
        ret.smega = ct.smega;
        ret.gashponmega = ct.gashponmega;
        ret.id = ct.characterid;
        ret.name = ct.name;
        ret.level = ct.level;
        ret.fame = ct.fame;
        ret.CRand = new PlayerRandomStream();
        ret.stats.str = ct.str;
        ret.stats.dex = ct.dex;
        ret.stats.int_ = ct.int_;
        ret.stats.luk = ct.luk;
        ret.stats.maxhp = ct.maxhp;
        ret.stats.maxmp = ct.maxmp;
        ret.stats.hp = ct.hp;
        ret.stats.mp = ct.mp;
        ret.chalktext = ct.chalkboard;
        ret.exp = ((ret.level >= ret.maxLevel) ? 0 : ct.exp);
        ret.hpmpApUsed = ct.hpApUsed;
        ret.remainingSp = ct.remainingSp;
        ret.remainingAp = ct.remainingAp;
        ret.savedHairs = ct.savedHairs;
        ret.savedFaces = ct.savedFaces;
        ret.beans = ct.beans;
        ret.meso = ct.meso;
        ret.gmLevel = ct.gmLevel;
        ret.skinColor = ct.skinColor;
        ret.gender = ct.gender;
        ret.job = ct.job;
        ret.hair = ct.hair;
        ret.face = ct.face;
        ret.accountid = ct.accountid;
        ret.mapid = ct.mapid;
        ret.initialSpawnPoint = ct.initialSpawnPoint;
        ret.limitBreak = ct.limitBreak;
        ret.reinNumber = ct.reinNumber;
        ret.world = ct.world;
        ret.bookCover = ct.mBookCover;
        ret.dojo = ct.dojo;
        ret.dojoRecord = ct.dojoRecord;
        ret.guildid = ct.guildid;
        ret.guildrank = ct.guildrank;
        ret.allianceRank = ct.alliancerank;
        ret.CsMod = ct.CsMod;
        ret.vpoints = ct.vpoints;
        ret.vip = ct.vip;
        ret.mrqdTime = ct.mrqdTime;
        ret.fairyExp = ct.fairyExp;
        ret.marriageId = ct.marriageId;
        ret.currentrep = ct.currentrep;
        ret.totalrep = ct.totalrep;
        ret.charmessage = ct.charmessage;
        ret.expression = ct.expression;
        ret.constellation = ct.constellation;
        ret.blood = ct.blood;
        ret.month = ct.month;
        ret.day = ct.day;
        ret.gachexp = ct.gachexp;
        ret.makeMFC(ct.familyid, ct.seniorid, ct.junior1, ct.junior2);
        if (ret.guildid > 0) {
            ret.mgc = new MapleGuildCharacter(ret);
        }
        ret.buddylist = new BuddyList(ct.buddysize);
        ret.subcategory = ct.subcategory;
        ret.prefix = ct.prefix;
        if (isChannel) {
            MapleMapFactory mapFactory = ChannelServer.getInstance(client.getChannel()).getMapFactory();
            ret.map = mapFactory.getMap(ret.mapid);
            if (ret.map != null) {
                if (ret.mapid == 801000110 || ret.mapid == 801000210) {
                    ret.map = mapFactory.getMap(801000000);
                }
                if (ret.mapid >= 211060000 && ret.mapid <= 211070200) {
                    ret.map = mapFactory.getMap(211060000);
                }
            }
            if (ret.map == null) {
                ret.map = mapFactory.getMap(100000000);
            } else if (ret.map.getForcedReturnId() != 999999999) {
                ret.map = ret.map.getForcedReturnMap();
            }
            MaplePortal portal = ret.map.getPortal((int) ret.initialSpawnPoint);
            if (portal == null) {
                portal = ret.map.getPortal(0);
                ret.initialSpawnPoint = 0;
            }
            ret.setPosition(portal.getPosition());
            int messengerid = ct.messengerid;
            if (messengerid > 0) {
                ret.messenger = Messenger.getMessenger(messengerid);
            }
        } else {
            ret.messenger = null;
        }
        int partyid = ct.partyid;
        if (partyid >= 0) {
            MapleParty party = Party.getParty(partyid);
            if (party != null && party.getMemberById(ret.id) != null) {
                ret.party = party;
            }
        }
        for (Entry<Integer, Object> qs : ct.Quest.entrySet()) {
            MapleQuest quest = MapleQuest.getInstance(((Integer) qs.getKey()).intValue());
            MapleQuestStatus queststatus_from = (MapleQuestStatus) qs.getValue();
            MapleQuestStatus queststatus = new MapleQuestStatus(quest, (int) queststatus_from.getStatus());
            queststatus.setForfeited(queststatus_from.getForfeited());
            queststatus.setCustomData(queststatus_from.getCustomData());
            queststatus.setCompletionTime(queststatus_from.getCompletionTime());
            if (queststatus_from.getMobKills() != null) {
                for (Entry<Integer, Integer> mobkills : queststatus_from.getMobKills().entrySet()) {
                    queststatus.setMobKills(((Integer) mobkills.getKey()).intValue(), ((Integer) mobkills.getValue()).intValue());
                }
            }
            ret.quests.put(quest, queststatus);
        }
        for (Entry<Integer, SkillEntry> qs2 : ct.Skills.entrySet()) {
            ret.skills.put(SkillFactory.getSkill(((Integer) qs2.getKey()).intValue()), qs2.getValue());
        }
        for (Integer zz : ct.finishedAchievements) {
            ret.finishedAchievements.add(zz);
        }
        ret.monsterbook = new MonsterBook(ct.mbook);
        ret.inventory = (MapleInventory[]) (MapleInventory[]) ct.inventorys;
        ret.BlessOfFairy_Origin = ct.BlessOfFairy;
        ret.skillMacros = (SkillMacro[]) (SkillMacro[]) ct.skillmacro;
        ret.petStore = ct.petStore;
        ret.keylayout = new MapleKeyLayout(ct.keymap);
        ret.questinfo = ct.InfoQuest;
        ret.savedLocations = ct.savedlocation;
        ret.wishlist = ct.wishlist;
        ret.rocks = ct.rocks;
        ret.regrocks = ct.regrocks;
        ret.buddylist.loadFromTransfer(ct.buddies);
        ret.keydown_skill = 0L;
        ret.lastfametime = ct.lastfametime;
        ret.lastmonthfameids = ct.famedcharacters;
        ret.storage = (MapleStorage) ct.storage;
        ret.cs = (CashShop) ct.cs;
        client.setAccountName(ct.accountname);
        ret.maplepoints = ct.MaplePoints;
        ret.accountsecondPassword = ct.accountsecondPassword;
        ret.loginkey = ct.loginkey;
        ret.serverkey = ct.serverkey;
        ret.clientkey = ct.clientkey;
        ret.antiMacro = (MapleLieDetector) ct.antiMacro;
        ret.numClones = ct.clonez;
        ret.mount = new MapleMount(ret, ct.mount_itemid, GameConstants.isKOC((int) ret.job) ? 10001004 : (GameConstants.isAran((int) ret.job) ? 20001004 : 1004), ct.mount_Fatigue, ct.mount_level, ct.mount_exp);
        ret.stats.recalcLocalStats(true);
        return ret;
    }

    public static MapleCharacter loadCharFromDB(int charid, MapleClient client, boolean channelserver) {
        MapleCharacter ret = new MapleCharacter(channelserver);
        ret.client = client;
        ret.id = charid;
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = null;
            ResultSet rs = null;
            try {
                ps = con.prepareStatement("SELECT * FROM characters WHERE id = ?");
                ps.setInt(1, charid);
                rs = ps.executeQuery();
                if (!rs.next()) {
                    throw new RuntimeException("Loading the Char Failed (char not found)");
                }
                ret.Vip_Medal = (rs.getShort("VipMedal") > 0);
                ret.name = rs.getString("name");
                ret.level = rs.getShort("level");
                ret.fame = rs.getShort("fame");
                ret.stats.str = rs.getShort("str");
                ret.stats.dex = rs.getShort("dex");
                ret.stats.int_ = rs.getShort("int");
                ret.stats.luk = rs.getShort("luk");
                ret.stats.maxhp = rs.getShort("maxhp");
                ret.stats.maxmp = rs.getShort("maxmp");
                ret.stats.hp = rs.getShort("hp");
                ret.stats.mp = rs.getShort("mp");
                ret.exp = ((ret.level >= ret.maxLevel) ? 0 : rs.getInt("exp"));
                ret.hpmpApUsed = rs.getShort("hpApUsed");
                String[] sp = rs.getString("sp").split(",");
                for (int i = 0; i < ret.remainingSp.length; ++i) {
                    ret.remainingSp[i] = Integer.parseInt(sp[i]);
                }
                String[] saves_faces = rs.getString("saved_faces").split(",");
                for (int j = 0; j < ret.savedFaces.length; ++j) {
                    ret.savedFaces[j] = Integer.parseInt(saves_faces[j]);
                }
                String[] saves_hairs = rs.getString("saved_hairs").split(",");
                for (int k = 0; k < ret.savedHairs.length; ++k) {
                    ret.savedHairs[k] = Integer.parseInt(saves_hairs[k]);
                }
                ret.remainingAp = rs.getShort("ap");
                ret.beans = rs.getInt("beans");
                ret.meso = rs.getInt("meso");
                ret.gmLevel = rs.getByte("gm");
                ret.skinColor = rs.getByte("skincolor");
                ret.gender = rs.getByte("gender");
                ret.job = rs.getShort("job");
                ret.hair = rs.getInt("hair");
                ret.face = rs.getInt("face");
                ret.accountid = rs.getInt("accountid");
                ret.mapid = rs.getInt("map");
                ret.initialSpawnPoint = rs.getByte("spawnpoint");
                ret.world = rs.getByte("world");
                ret.guildid = rs.getInt("guildid");
                ret.guildrank = rs.getByte("guildrank");
                ret.allianceRank = rs.getByte("allianceRank");
                ret.currentrep = rs.getInt("currentrep");
                ret.totalrep = rs.getInt("totalrep");
                ret.makeMFC(rs.getInt("familyid"), rs.getInt("seniorid"), rs.getInt("junior1"), rs.getInt("junior2"));
                if (ret.guildid > 0) {
                    ret.mgc = new MapleGuildCharacter(ret);
                }
                ret.buddylist = new BuddyList(rs.getByte("buddyCapacity"));
                ret.subcategory = rs.getByte("subcategory");
                ret.mount = new MapleMount(ret, 0, (ret.job > 1000 && ret.job < 2000) ? 10001004 : ((ret.job >= 2000) ? ((ret.job == 2001 || (ret.job >= 2200 && ret.job <= 2218)) ? 20011004 : ((ret.job >= 3000) ? 30001004 : 20001004)) : 1004), (byte) 0, (byte) 1, 0);
                ret.rank = rs.getInt("rank");
                ret.rankMove = rs.getInt("rankMove");
                ret.jobRank = rs.getInt("jobRank");
                ret.jobRankMove = rs.getInt("jobRankMove");
                ret.marriageId = rs.getInt("marriageId");
                ret.charmessage = rs.getString("charmessage");
                ret.expression = rs.getInt("expression");
                ret.constellation = rs.getInt("constellation");
                ret.blood = rs.getInt("blood");
                ret.month = rs.getInt("month");
                ret.schoolIntegral = rs.getInt("school_integral");
                ret.day = rs.getInt("day");
                ret.prefix = rs.getString("prefix");
                ret.gachexp = rs.getInt("gachexp");
                ret.limitBreak = rs.getLong("limitBreak");
                ret.reinNumber = rs.getInt("reinNumber");
                if (channelserver) {
                    MapleMapFactory mapFactory = ChannelServer.getInstance(client.getChannel()).getMapFactory();
                    ret.antiMacro = new MapleLieDetector(ret.id);
                    ret.map = mapFactory.getMap(ret.mapid);
                    if (ret.mapid == 801000210) {
                        ret.map = mapFactory.getMap(801000000);
                    }
                    if (ret.mapid == 801000110) {
                        ret.map = mapFactory.getMap(801000000);
                    }
                    if (ret.map == null) {
                        ret.map = mapFactory.getMap(100000000);
                    }
                    MaplePortal portal = ret.map.getPortal((int) ret.initialSpawnPoint);
                    if (portal == null) {
                        portal = ret.map.getPortal(0);
                        ret.initialSpawnPoint = 0;
                    }
                    ret.setPosition(portal.getPosition());
                    int partyid = rs.getInt("party");
                    if (partyid >= 0) {
                        MapleParty party = Party.getParty(partyid);
                        if (party != null && party.getMemberById(ret.id) != null) {
                            ret.party = party;
                        }
                    }
                    ret.bookCover = rs.getInt("monsterbookcover");
                    ret.dojo = rs.getInt("dojo_pts");
                    ret.dojoRecord = rs.getByte("dojoRecord");
                    String[] pets = rs.getString("pets").split(",");
                    for (int l = 0; l < ret.petStore.length; ++l) {
                        ret.petStore[l] = Byte.parseByte(pets[l]);
                    }
                    rs.close();
                    ps.close();
                    ps = con.prepareStatement("SELECT achievementid FROM achievements WHERE accountid = ?");
                    ps.setInt(1, ret.accountid);
                    rs = ps.executeQuery();
                    while (rs.next()) {
                        ret.finishedAchievements.add(Integer.valueOf(rs.getInt("achievementid")));
                    }
                }
                rs.close();
                ps.close();
                boolean compensate_previousEvans = false;
                ps = con.prepareStatement("SELECT * FROM queststatus WHERE characterid = ?");
                ps.setInt(1, charid);
                rs = ps.executeQuery();
                PreparedStatement pse = con.prepareStatement("SELECT * FROM queststatusmobs WHERE queststatusid = ?");
                while (rs.next()) {
                    int id = rs.getInt("quest");
                    if (id == 170000) {
                        compensate_previousEvans = true;
                    }
                    MapleQuest q = MapleQuest.getInstance(id);
                    MapleQuestStatus status = new MapleQuestStatus(q, (int) rs.getByte("status"));
                    long cTime = rs.getLong("time");
                    if (cTime > -1L) {
                        status.setCompletionTime(cTime * 1000L);
                    }
                    status.setForfeited(rs.getInt("forfeited"));
                    status.setCustomData(rs.getString("customData"));
                    ret.quests.put(q, status);
                    pse.setLong(1, rs.getLong("queststatusid"));
                    try (ResultSet rsMobs = pse.executeQuery()) {
                        while (rsMobs.next()) {
                            status.setMobKills(rsMobs.getInt("mob"), rsMobs.getInt("count"));
                        }
                    }
                }
                rs.close();
                ps.close();
                pse.close();
                if (channelserver) {
                    ret.CRand = new PlayerRandomStream();
                    ret.monsterbook = MonsterBook.loadCards(charid);
                    ps = con.prepareStatement("SELECT * FROM inventoryslot where characterid = ?");
                    ps.setInt(1, charid);
                    rs = ps.executeQuery();
                    if (!rs.next()) {
                        throw new RuntimeException("No Inventory slot column found in SQL. [inventoryslot]");
                    }
                    ret.getInventory(MapleInventoryType.EQUIP).setSlotLimit(rs.getByte("equip"));
                    ret.getInventory(MapleInventoryType.USE).setSlotLimit(rs.getByte("use"));
                    ret.getInventory(MapleInventoryType.SETUP).setSlotLimit(rs.getByte("setup"));
                    ret.getInventory(MapleInventoryType.ETC).setSlotLimit(rs.getByte("etc"));
                    ret.getInventory(MapleInventoryType.CASH).setSlotLimit(rs.getByte("cash"));
                    ps.close();
                    rs.close();
                    for (Pair<IItem, MapleInventoryType> mit : ItemLoader.INVENTORY.loadItems(false, Integer.valueOf(charid)).values()) {
                        ret.getInventory((MapleInventoryType) mit.getRight()).addFromDB((IItem) mit.getLeft());
                        if (((IItem) mit.getLeft()).getPet() != null) {
                            ret.pets.add(((IItem) mit.getLeft()).getPet());
                        }
                    }
                    ps = con.prepareStatement("SELECT name, 2ndpassword, mPoints, vpoints, VIP, loginkey, serverkey, clientkey FROM accounts WHERE id = ?");
                    ps.setInt(1, ret.accountid);
                    rs = ps.executeQuery();
                    if (rs.next()) {
                        ret.getClient().setAccountName(rs.getString("name"));
                        ret.accountsecondPassword = rs.getString("2ndpassword");
                        ret.maplepoints = rs.getInt("mPoints");
                        ret.vpoints = rs.getInt("vpoints");
                        ret.vip = rs.getInt("VIP");
                        ret.loginkey = rs.getString("loginkey");
                        ret.serverkey = rs.getString("serverkey");
                        ret.clientkey = rs.getString("clientkey");
                    } else {
                        rs.close();
                    }
                    ps.close();
                    ps = con.prepareStatement("SELECT quest, customData FROM questinfo WHERE characterid = ?");
                    ps.setInt(1, charid);
                    rs = ps.executeQuery();
                    while (rs.next()) {
                        ret.questinfo.put(Integer.valueOf(rs.getInt("quest")), rs.getString("customData"));
                    }
                    rs.close();
                    ps.close();
                    ps = con.prepareStatement("SELECT skillid, skilllevel, masterlevel, expiration FROM skills WHERE characterid = ?");
                    ps.setInt(1, charid);
                    rs = ps.executeQuery();
                    while (rs.next()) {
                        ISkill skil = SkillFactory.getSkill(rs.getInt("skillid"));
                        if (skil != null && GameConstants.isApplicableSkill(rs.getInt("skillid")) && rs.getByte("skilllevel") >= 0) {
                            ret.skills.put(skil, new SkillEntry(rs.getByte("skilllevel"), rs.getByte("masterlevel"), rs.getLong("expiration")));
                        } else {
                            if (skil != null) {
                                continue;
                            }
                            int[] remainingSp = ret.remainingSp;
                            int skillBookForSkill = GameConstants.getSkillBookForSkill(rs.getInt("skillid"));
                            remainingSp[skillBookForSkill] += rs.getByte("skilllevel");
                        }
                    }
                    rs.close();
                    ps.close();
                    ret.expirationTask(false);
                    ps = con.prepareStatement("SELECT id, name, level FROM characters WHERE accountid = ? ORDER BY level DESC");
                    ps.setInt(1, ret.accountid);
                    rs = ps.executeQuery();
                    byte maxlevel_ = 0;
                    while (rs.next()) {
                        if (rs.getInt("id") != charid) {
                            byte maxlevel = (byte) (rs.getShort("level") / 10);
                            if (maxlevel > 20) {
                                maxlevel = 20;
                            }
                            if (maxlevel <= maxlevel_) {
                                continue;
                            }
                            maxlevel_ = maxlevel;
                            ret.BlessOfFairy_Origin = rs.getString("name");
                        } else {
                            if (charid >= 17000 || compensate_previousEvans || ret.job < 2200 || ret.job > 2218) {
                                continue;
                            }
                            for (int m = 0; m <= GameConstants.getSkillBook((int) ret.job); ++m) {
                                int[] remainingSp2 = ret.remainingSp;
                                int n = m;
                                remainingSp2[n] += 2;
                            }
                            ret.setQuestAdd(MapleQuest.getInstance(170000), (byte) 0, null);
                        }
                    }
                    ret.skills.put(SkillFactory.getSkill(GameConstants.getBofForJob((int) ret.job)), new SkillEntry(maxlevel_, (byte) 0, -1L));
                    ps.close();
                    rs.close();
                    ps = con.prepareStatement("SELECT * FROM skillmacros WHERE characterid = ?");
                    ps.setInt(1, charid);
                    rs = ps.executeQuery();
                    while (rs.next()) {
                        int position = rs.getInt("position");
                        SkillMacro macro = new SkillMacro(rs.getInt("skill1"), rs.getInt("skill2"), rs.getInt("skill3"), rs.getString("name"), rs.getInt("shout"), position);
                        ret.skillMacros[position] = macro;
                    }
                    rs.close();
                    ps.close();
                    ps = con.prepareStatement("SELECT `key`,`type`,`action` FROM keymap WHERE characterid = ?");
                    ps.setInt(1, charid);
                    rs = ps.executeQuery();
                    Map<Integer, Pair<Byte, Integer>> keyb = ret.keylayout.Layout();
                    while (rs.next()) {
                        keyb.put(Integer.valueOf(rs.getInt("key")), new Pair(Byte.valueOf(rs.getByte("type")), Integer.valueOf(rs.getInt("action"))));
                    }
                    rs.close();
                    ps.close();
                    ps = con.prepareStatement("SELECT `locationtype`,`map` FROM savedlocations WHERE characterid = ?");
                    ps.setInt(1, charid);
                    rs = ps.executeQuery();
                    while (rs.next()) {
                        ret.savedLocations[rs.getInt("locationtype")] = rs.getInt("map");
                    }
                    rs.close();
                    ps.close();
                    ps = con.prepareStatement("SELECT `characterid_to`,`when` FROM famelog WHERE characterid = ? AND DATEDIFF(NOW(),`when`) < 30");
                    ps.setInt(1, charid);
                    rs = ps.executeQuery();
                    ret.lastfametime = 0L;
                    ret.lastmonthfameids = (List<Integer>) new ArrayList(31);
                    while (rs.next()) {
                        ret.lastfametime = Math.max(ret.lastfametime, rs.getTimestamp("when").getTime());
                        ret.lastmonthfameids.add(Integer.valueOf(rs.getInt("characterid_to")));
                    }
                    rs.close();
                    ps.close();
                    ret.buddylist.loadFromDb(charid);
                    ret.storage = MapleStorage.loadStorage(ret.accountid);
                    ret.cs = new CashShop(ret.accountid, charid, (int) ret.getJob());
                    ps = con.prepareStatement("SELECT sn FROM wishlist WHERE characterid = ?");
                    ps.setInt(1, charid);
                    rs = ps.executeQuery();
                    int i2 = 0;
                    while (rs.next()) {
                        ret.wishlist[i2] = rs.getInt("sn");
                        ++i2;
                    }
                    while (i2 < 10) {
                        ret.wishlist[i2] = 0;
                        ++i2;
                    }
                    rs.close();
                    ps.close();
                    ps = con.prepareStatement("SELECT mapid FROM trocklocations WHERE characterid = ?");
                    ps.setInt(1, charid);
                    rs = ps.executeQuery();
                    int r = 0;
                    while (rs.next()) {
                        ret.rocks[r] = rs.getInt("mapid");
                        ++r;
                    }
                    while (r < 10) {
                        ret.rocks[r] = 999999999;
                        ++r;
                    }
                    rs.close();
                    ps.close();
                    ps = con.prepareStatement("SELECT mapid FROM regrocklocations WHERE characterid = ?");
                    ps.setInt(1, charid);
                    rs = ps.executeQuery();
                    r = 0;
                    while (rs.next()) {
                        ret.regrocks[r] = rs.getInt("mapid");
                        ++r;
                    }
                    while (r < 5) {
                        ret.regrocks[r] = 999999999;
                        ++r;
                    }
                    rs.close();
                    ps.close();
                    ps = con.prepareStatement("SELECT * FROM mountdata WHERE characterid = ?");
                    ps.setInt(1, charid);
                    rs = ps.executeQuery();
                    if (!rs.next()) {
                        throw new RuntimeException("No mount data found on SQL column");
                    }
                    IItem mount = ret.getInventory(MapleInventoryType.EQUIPPED).getItem((short) (-18));
                    ret.mount = new MapleMount(ret, (mount != null) ? mount.getItemId() : 0, (ret.job > 1000 && ret.job < 2000) ? 10001004 : ((ret.job >= 2000) ? ((ret.job == 2001 || ret.job >= 2200) ? 20011004 : ((ret.job >= 3000) ? 30001004 : 20001004)) : 1004), rs.getByte("Fatigue"), rs.getByte("Level"), rs.getInt("Exp"));
                    ps.close();
                    rs.close();
                    ret.stats.recalcLocalStats(true);
                } else {
                    for (Pair<IItem, MapleInventoryType> mit : ItemLoader.INVENTORY.loadItems(true, Integer.valueOf(charid)).values()) {
                        ret.getInventory((MapleInventoryType) mit.getRight()).addFromDB((IItem) mit.getLeft());
                    }
                }
            } catch (SQLException ess) {
                ess.printStackTrace();
                FileoutputUtil.outError("logs/读取MapleCharacter.txt", (Throwable) ess);
                FilePrinter.printError("MapleCharacter.txt", (Throwable) ess, "载入角色失败..");
                try {
                    if (ps != null) {
                        ps.close();
                    }
                    if (rs != null) {
                        rs.close();
                    }
                } catch (SQLException ignore) {
                    ignore.printStackTrace();
                    FileoutputUtil.outError("logs/读取MapleCharacter.txt", (Throwable) ignore);
                    FilePrinter.printError("MapleCharacter.txt", (Throwable) ignore, "载入角色失败..");
                }
            } finally {
                try {
                    if (ps != null) {
                        ps.close();
                    }
                    if (rs != null) {
                        rs.close();
                    }
                } catch (SQLException ignore2) {
                    ignore2.printStackTrace();
                    FileoutputUtil.outError("logs/读取MapleCharacter.txt", (Throwable) ignore2);
                    FilePrinter.printError("MapleCharacter.txt", (Throwable) ignore2, "载入角色失败..");
                }
            }
        } catch (SQLException exxx) {
            FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) exxx);
        }
        return ret;
    }

    public static void saveNewCharToDB(MapleCharacter chr, int type, boolean db) {
        PreparedStatement ps = null;
        PreparedStatement pse = null;
        ResultSet rs = null;
        try (Connection con = BeePool.getConnection()) {
            con.setTransactionIsolation(Connection.TRANSACTION_READ_UNCOMMITTED);
            con.setAutoCommit(false);
            ps = con.prepareStatement("INSERT INTO characters (level, fame, str, dex, luk, `int`, exp, hp, mp, maxhp, maxmp, sp, ap, gm, skincolor, gender, job, hair, face, map, meso, hpApUsed, spawnpoint, party, buddyCapacity, monsterbookcover, dojo_pts, dojoRecord, pets, subcategory, marriageId, currentrep, totalrep, prefix, accountid, name, world, VipMedal,limitBreak,reinNumber) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", 1);
            ps.setInt(1, 1);
            ps.setShort(2, (short) 0);
            PlayerStats stat = chr.stats;
            ps.setShort(3, stat.getStr());
            ps.setShort(4, stat.getDex());
            ps.setShort(5, stat.getInt());
            ps.setShort(6, stat.getLuk());
            ps.setInt(7, 0);
            ps.setShort(8, stat.getHp());
            ps.setShort(9, stat.getMp());
            ps.setShort(10, stat.getMaxHp());
            ps.setShort(11, stat.getMaxMp());
            ps.setString(12, "0,0,0,0,0,0,0,0,0,0");
            ps.setShort(13, (short) 0);
            ps.setByte(14, (byte) 0);
            ps.setByte(15, chr.skinColor);
            ps.setByte(16, chr.gender);
            ps.setShort(17, chr.job);
            ps.setInt(18, chr.hair);
            ps.setInt(19, chr.face);
            ps.setInt(20, (type == 1) ? 0 : ((type == 0) ? 130030000 : ((type == 3) ? 900090000 : 914000000)));
            ps.setInt(21, chr.meso);
            ps.setShort(22, (short) 0);
            ps.setByte(23, (byte) 0);
            ps.setInt(24, -1);
            ps.setByte(25, chr.buddylist.getCapacity());
            ps.setInt(26, 0);
            ps.setInt(27, 0);
            ps.setInt(28, 0);
            ps.setString(29, "-1,-1,-1");
            ps.setInt(30, 0);
            ps.setInt(31, 0);
            ps.setInt(32, 0);
            ps.setInt(33, 0);
            ps.setString(34, chr.prefix);
            ps.setInt(35, chr.getAccountID());
            ps.setString(36, chr.name);
            ps.setByte(37, chr.world);
            ps.setInt(38, (int) (chr.Vip_Medal ? 1 : 0));
            ps.setLong(39, chr.limitBreak);
            ps.setInt(40, chr.reinNumber);
            ps.executeUpdate();
            rs = ps.getGeneratedKeys();
            if (!rs.next()) {
                throw new RuntimeException("Inserting char failed.");
            }
            chr.id = rs.getInt(1);
            ps.close();
            rs.close();
            ps = con.prepareStatement("INSERT INTO queststatus (`queststatusid`, `characterid`, `quest`, `status`, `time`, `forfeited`, `customData`) VALUES (DEFAULT, ?, ?, ?, ?, ?, ?)", 1);
            pse = con.prepareStatement("INSERT INTO queststatusmobs VALUES (DEFAULT, ?, ?, ?)");
            ps.setInt(1, chr.id);
            for (MapleQuestStatus q : chr.quests.values()) {
                ps.setInt(2, q.getQuest().getId());
                ps.setInt(3, (int) q.getStatus());
                ps.setInt(4, (int) (q.getCompletionTime() / 1000L));
                ps.setInt(5, q.getForfeited());
                ps.setString(6, q.getCustomData());
                ps.executeUpdate();
                rs = ps.getGeneratedKeys();
                rs.next();
                if (q.hasMobKills()) {
                    for (Integer integer : q.getMobKills().keySet()) {
                        int mob = integer;
                        pse.setLong(1, rs.getLong(1));
                        pse.setInt(2, mob);
                        pse.setInt(3, q.getMobKills(mob));
                        pse.executeUpdate();
                    }
                }
                rs.close();
            }
            ps.close();
            pse.close();
            ps = con.prepareStatement("INSERT INTO inventoryslot (characterid, `equip`, `use`, `setup`, `etc`, `cash`) VALUES (?, ?, ?, ?, ?, ?)");
            ps.setInt(1, chr.id);
            ps.setByte(2, (byte) 32);
            ps.setByte(3, (byte) 32);
            ps.setByte(4, (byte) 32);
            ps.setByte(5, (byte) 32);
            ps.setByte(6, (byte) 60);
            ps.execute();
            ps.close();
            ps = con.prepareStatement("INSERT INTO mountdata (characterid, `Level`, `Exp`, `Fatigue`) VALUES (?, ?, ?, ?)");
            ps.setInt(1, chr.id);
            ps.setByte(2, (byte) 1);
            ps.setInt(3, 0);
            ps.setByte(4, (byte) 0);
            ps.execute();
            ps.close();
            List<Pair<IItem, MapleInventoryType>> listing = (List<Pair<IItem, MapleInventoryType>>) new ArrayList();
            for (MapleInventory iv : chr.inventory) {
                for (IItem item : iv.list()) {
                    listing.add(new Pair(item, iv.getType()));
                }
            }
            ItemLoader.INVENTORY.saveItems(listing, con, Integer.valueOf(chr.id));
            int[] array1 = {2, 3, 4, 5, 6, 7, 16, 17, 18, 19, 23, 25, 26, 27, 29, 31, 34, 35, 37, 38, 40, 41, 43, 44, 45, 46, 48, 50, 56, 57, 59, 60, 61, 62, 63, 64, 65};
            int[] array2 = {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 4, 4, 4, 5, 5, 6, 6, 6, 6, 6, 6, 6};
            int[] array3 = {10, 12, 13, 18, 24, 21, 8, 5, 0, 4, 1, 19, 14, 15, 52, 2, 17, 11, 3, 20, 16, 23, 9, 50, 51, 6, 22, 7, 53, 54, 100, 101, 102, 103, 104, 105, 106};
            ps = con.prepareStatement("INSERT INTO keymap (characterid, `key`, `type`, `action`) VALUES (?, ?, ?, ?)");
            ps.setInt(1, chr.id);
            for (int i = 0; i < array1.length; ++i) {
                ps.setInt(2, array1[i]);
                ps.setInt(3, array2[i]);
                ps.setInt(4, array3[i]);
                ps.execute();
            }
            ps.close();
            con.commit();
        } catch (SQLException e) {
            FilePrinter.printError("MapleCharacter.txt", (Throwable) e, "[角色存档] 储存角色资料失败");
            FileoutputUtil.outError("logs/MapleCharacter1.txt", (Throwable) e);
            FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) e);
        }
    }

    public int saveToDB(boolean dc, boolean fromcs) {
        if (this.isClone()) {
            return -1;
        }
        int retValue = 1;
        PreparedStatement ps = null;
        PreparedStatement pse = null;
        ResultSet rs = null;
        try (Connection con = BeePool.getConnection()) {
            con.setTransactionIsolation(1);
            con.setAutoCommit(false);
            ps = con.prepareStatement("UPDATE characters SET level = ?, fame = ?, str = ?, dex = ?, luk = ?, `int` = ?, exp = ?, hp = ?, mp = ?, maxhp = ?, maxmp = ?, sp = ?, ap = ?, gm = ?, skincolor = ?, gender = ?, job = ?, hair = ?, face = ?, map = ?, meso = ?, hpApUsed = ?, spawnpoint = ?, party = ?, buddyCapacity = ?, monsterbookcover = ?, dojo_pts = ?, dojoRecord = ?, pets = ?, subcategory = ?, marriageId = ?, currentrep = ?, totalrep = ?, charmessage = ?, expression = ?, constellation = ?, blood = ?, month = ?, day = ?, beans = ?, prefix = ?, gachexp = ?, name = ?, VipMedal = ?, saved_faces = ?, saved_hairs = ?, limitBreak = ? , reinNumber = ? ,school_integral =? WHERE id = ?");
            ps.setInt(1, (int) this.level);
            ps.setShort(2, this.fame);
            ps.setShort(3, this.stats.getStr());
            ps.setShort(4, this.stats.getDex());
            ps.setShort(5, this.stats.getLuk());
            ps.setShort(6, this.stats.getInt());
            ps.setLong(7, (this.level >= this.maxLevel) ? 0L : ((long) this.exp));
            ps.setShort(8, (short) ((this.stats.getHp() < 1) ? 50 : this.stats.getHp()));
            ps.setShort(9, this.stats.getMp());
            ps.setShort(10, this.stats.getMaxHp());
            ps.setShort(11, this.stats.getMaxMp());
            StringBuilder sps = new StringBuilder();
            for (int i = 0; i < this.remainingSp.length; ++i) {
                sps.append(this.remainingSp[i]);
                sps.append(",");
            }
            String sp = sps.toString();
            ps.setString(12, sp.substring(0, sp.length() - 1));
            ps.setShort(13, this.remainingAp);
            ps.setByte(14, this.gmLevel);
            ps.setByte(15, this.skinColor);
            ps.setByte(16, this.gender);
            ps.setShort(17, this.job);
            ps.setInt(18, this.hair);
            ps.setInt(19, this.face);
            if (!fromcs && this.map != null) {
                if (this.map.getForcedReturnId() != 999999999) {
                    if (this.map.getId() == 220080001) {
                        ps.setInt(20, 910000000);
                    } else {
                        ps.setInt(20, this.map.getForcedReturnId());
                    }
                } else {
                    ps.setInt(20, (this.stats.getHp() < 1) ? this.map.getReturnMapId() : this.map.getId());
                }
            } else {
                ps.setInt(20, this.mapid);
            }
            ps.setInt(21, this.meso);
            ps.setShort(22, this.hpmpApUsed);
            if (this.map == null) {
                ps.setByte(23, (byte) 0);
            } else {
                MaplePortal closest = this.map.findClosestSpawnpoint(this.getPosition());
                ps.setByte(23, (byte) ((closest != null) ? closest.getId() : 0));
            }
            ps.setInt(24, (this.party != null) ? this.party.getId() : -1);
            ps.setShort(25, (short) this.buddylist.getCapacity());
            ps.setInt(26, this.bookCover);
            ps.setInt(27, this.dojo);
            ps.setInt(28, (int) this.dojoRecord);
            StringBuilder petz = new StringBuilder();
            int petLength = 0;
            for (MaplePet pet : this.pets) {
                pet.saveToDb();
                if (pet.getSummoned()) {
                    petz.append((int) pet.getInventoryPosition());
                    petz.append(",");
                    ++petLength;
                }
            }
            while (petLength < 3) {
                petz.append("-1,");
                ++petLength;
            }
            String petstring = petz.toString();
            ps.setString(29, petstring.substring(0, petstring.length() - 1));
            ps.setByte(30, this.subcategory);
            ps.setInt(31, this.marriageId);
            ps.setInt(32, this.currentrep);
            ps.setInt(33, this.totalrep);
            ps.setString(34, this.charmessage);
            ps.setInt(35, this.expression);
            ps.setInt(36, this.constellation);
            ps.setInt(37, this.blood);
            ps.setInt(38, this.month);
            ps.setInt(39, this.day);
            ps.setInt(40, this.beans);
            ps.setString(41, this.prefix);
            ps.setInt(42, this.gachexp);
            ps.setString(43, this.name);
            ps.setInt(44, (int) (this.Vip_Medal ? 1 : 0));
            StringBuilder faces = new StringBuilder();
            for (int j = 0; j < this.savedFaces.length; ++j) {
                faces.append(this.savedFaces[j]);
                faces.append(",");
            }
            String saved_faces = faces.toString();
            ps.setString(45, saved_faces.substring(0, saved_faces.length() - 1));
            StringBuilder hairs = new StringBuilder();
            for (int k = 0; k < this.savedHairs.length; ++k) {
                hairs.append(this.savedHairs[k]);
                hairs.append(",");
            }
            String saved_hairs = hairs.toString();
            ps.setString(46, saved_hairs.substring(0, saved_hairs.length() - 1));
            ps.setLong(47, this.limitBreak);
            ps.setInt(48, this.reinNumber);
            ps.setInt(49, this.schoolIntegral);
            ps.setInt(50, this.id);
            if (ps.executeUpdate() < 1) {
                ps.close();
                throw new RuntimeException("Character not in database (" + this.id + ")");
            }
            ps.close();
            this.deleteWhereCharacterId(con, "DELETE FROM skillmacros WHERE characterid = ?");
            for (int l = 0; l < 5; ++l) {
                SkillMacro macro = this.skillMacros[l];
                ps = con.prepareStatement("INSERT INTO skillmacros (characterid, skill1, skill2, skill3, name, shout, position) VALUES (?, ?, ?, ?, ?, ?, ?)");
                if (macro != null) {
                    ps.setInt(1, this.id);
                    ps.setInt(2, macro.getSkill1());
                    ps.setInt(3, macro.getSkill2());
                    ps.setInt(4, macro.getSkill3());
                    ps.setString(5, macro.getName());
                    ps.setInt(6, macro.getShout());
                    ps.setInt(7, l);
                    ps.execute();
                    ps.close();
                }
            }
            this.deleteWhereCharacterId(con, "DELETE FROM inventoryslot WHERE characterid = ?");
            ps = con.prepareStatement("INSERT INTO inventoryslot (characterid, `equip`, `use`, `setup`, `etc`, `cash`) VALUES (?, ?, ?, ?, ?, ?)");
            ps.setInt(1, this.id);
            ps.setByte(2, this.getInventory(MapleInventoryType.EQUIP).getSlotLimit());
            ps.setByte(3, this.getInventory(MapleInventoryType.USE).getSlotLimit());
            ps.setByte(4, this.getInventory(MapleInventoryType.SETUP).getSlotLimit());
            ps.setByte(5, this.getInventory(MapleInventoryType.ETC).getSlotLimit());
            ps.setByte(6, this.getInventory(MapleInventoryType.CASH).getSlotLimit());
            ps.execute();
            ps.close();
            List<Pair<IItem, MapleInventoryType>> listing = (List<Pair<IItem, MapleInventoryType>>) new ArrayList();
            for (MapleInventory iv : this.inventory) {
                for (IItem item : iv.list()) {
                    listing.add(new Pair(item, iv.getType()));
                }
            }
            ItemLoader.INVENTORY.saveItems(listing, con, Integer.valueOf(this.id));
            this.deleteWhereCharacterId(con, "DELETE FROM questinfo WHERE characterid = ?");
            ps = con.prepareStatement("INSERT INTO questinfo (`characterid`, `quest`, `customData`) VALUES (?, ?, ?)");
            ps.setInt(1, this.id);
            for (Entry<Integer, String> q : this.questinfo.entrySet()) {
                ps.setInt(2, ((Integer) q.getKey()).intValue());
                ps.setString(3, (String) q.getValue());
                ps.execute();
            }
            ps.close();
            this.deleteWhereCharacterId(con, "DELETE FROM queststatus WHERE characterid = ?");
            ps = con.prepareStatement("INSERT INTO queststatus (`queststatusid`, `characterid`, `quest`, `status`, `time`, `forfeited`, `customData`) VALUES (DEFAULT, ?, ?, ?, ?, ?, ?)", 1);
            pse = con.prepareStatement("INSERT INTO queststatusmobs VALUES (DEFAULT, ?, ?, ?)", 1);
            ps.setInt(1, this.id);
            for (MapleQuestStatus q2 : this.quests.values()) {
                ps.setInt(2, q2.getQuest().getId());
                ps.setInt(3, q2.getStatus());
                ps.setInt(4, (int) (q2.getCompletionTime() / 1000L));
                ps.setInt(5, q2.getForfeited());
                ps.setString(6, q2.getCustomData());
                ps.executeUpdate();
                rs = ps.getGeneratedKeys();
                rs.next();
                if (q2.hasMobKills()) {
                    for (int mob : q2.getMobKills().keySet()) {
                        pse.setLong(1, rs.getLong(1));
                        pse.setInt(2, mob);
                        pse.setInt(3, q2.getMobKills(mob));
                        pse.executeUpdate();
                    }
                }
                rs.close();
            }
            ps.close();
            pse.close();
            this.deleteWhereCharacterId(con, "DELETE FROM skills WHERE characterid = ?");
            ps = con.prepareStatement("INSERT INTO skills (characterid, skillid, skilllevel, masterlevel, expiration) VALUES (?, ?, ?, ?, ?)");
            ps.setInt(1, this.id);
            for (Entry<ISkill, SkillEntry> skill : this.skills.entrySet()) {
                if (GameConstants.isApplicableSkill(((ISkill) skill.getKey()).getId())) {
                    ps.setInt(2, ((ISkill) skill.getKey()).getId());
                    ps.setByte(3, ((SkillEntry) skill.getValue()).skillevel);
                    ps.setByte(4, ((SkillEntry) skill.getValue()).masterlevel);
                    ps.setLong(5, ((SkillEntry) skill.getValue()).expiration);
                    ps.execute();
                }
            }
            ps.close();
            List<MapleCoolDownValueHolder> cd = this.getCooldowns();
            if (dc && cd.size() > 0) {
                ps = con.prepareStatement("INSERT INTO skills_cooldowns (charid, SkillID, StartTime, length) VALUES (?, ?, ?, ?)");
                ps.setInt(1, this.getId());
                for (MapleCoolDownValueHolder cooling : cd) {
                    ps.setInt(2, cooling.skillId);
                    ps.setLong(3, cooling.startTime);
                    ps.setLong(4, cooling.length);
                    ps.execute();
                }
                ps.close();
            }
            this.deleteWhereCharacterId(con, "DELETE FROM savedlocations WHERE characterid = ?");
            ps = con.prepareStatement("INSERT INTO savedlocations (characterid, `locationtype`, `map`) VALUES (?, ?, ?)");
            ps.setInt(1, this.id);
            for (SavedLocationType savedLocationType : SavedLocationType.values()) {
                if (this.savedLocations[savedLocationType.getValue()] != -1) {
                    ps.setInt(2, savedLocationType.getValue());
                    ps.setInt(3, this.savedLocations[savedLocationType.getValue()]);
                    ps.execute();
                }
            }
            ps.close();
            ps = con.prepareStatement("DELETE FROM achievements WHERE accountid = ?");
            ps.setInt(1, this.accountid);
            ps.executeUpdate();
            ps.close();
            ps = con.prepareStatement("INSERT INTO achievements(charid, achievementid, accountid) VALUES(?, ?, ?)");
            for (Integer achid : this.finishedAchievements) {
                ps.setInt(1, this.id);
                ps.setInt(2, achid);
                ps.setInt(3, this.accountid);
                ps.executeUpdate();
            }
            ps.close();
            this.deleteWhereCharacterId(con, "DELETE FROM buddies WHERE characterid = ?");
            ps = con.prepareStatement("INSERT INTO buddies (characterid, `buddyid`, `pending`) VALUES (?, ?, ?)");
            ps.setInt(1, this.id);
            for (BuddyEntry entry : this.buddylist.getBuddies()) {
                if (entry != null) {
                    ps.setInt(2, entry.getCharacterId());
                    ps.setInt(3, (int) (entry.isVisible() ? 0 : 1));
                    ps.execute();
                }
            }
            ps.close();
            ps = con.prepareStatement("UPDATE accounts SET `mPoints` = ?, `vpoints` = ?, `VIP` = ? WHERE id = ?");
            ps.setInt(1, this.maplepoints);
            ps.setInt(2, this.vpoints);
            ps.setInt(3, this.vip);
            ps.setInt(4, this.client.getAccID());
            ps.execute();
            ps.close();
            if (this.storage != null) {
                this.storage.saveToDB(con);
            }
            if (this.cs != null) {
                this.cs.save(con);
            }
            PlayerNPC.updateByCharId(this, con);
            this.keylayout.saveKeys(this.id, con);
            this.mount.saveMount(this.id, con);
            this.monsterbook.saveCards(this.id, con);
            this.deleteWhereCharacterId(con, "DELETE FROM wishlist WHERE characterid = ?");
            for (int m = 0; m < this.getWishlistSize(); ++m) {
                ps = con.prepareStatement("INSERT INTO wishlist(characterid, sn) VALUES(?, ?) ");
                ps.setInt(1, this.getId());
                ps.setInt(2, this.wishlist[m]);
                ps.execute();
                ps.close();
            }
            this.deleteWhereCharacterId(con, "DELETE FROM trocklocations WHERE characterid = ?");
            for (int rock : this.rocks) {
                if (rock != 999999999) {
                    ps = con.prepareStatement("INSERT INTO trocklocations(characterid, mapid) VALUES(?, ?) ");
                    ps.setInt(1, this.getId());
                    ps.setInt(2, rock);
                    ps.execute();
                    ps.close();
                }
            }
            this.deleteWhereCharacterId(con, "DELETE FROM regrocklocations WHERE characterid = ?");
            for (int regrock : this.regrocks) {
                if (regrock != 999999999) {
                    ps = con.prepareStatement("INSERT INTO regrocklocations(characterid, mapid) VALUES(?, ?) ");
                    ps.setInt(1, this.getId());
                    ps.setInt(2, regrock);
                    ps.execute();
                    ps.close();
                }
            }
            con.commit();
        } catch (Exception e) {
            retValue = 0;
            e.printStackTrace();
            System.out.println("保存数据出错" + e);
            FileoutputUtil.logToFile("logs/保存角色数据出错.txt", "\r\n " + FileoutputUtil.NowTime() + " IP: " + this.getClient().getSession().remoteAddress().toString().split(":")[0] + " 账号 " + this.getClient().getAccountName() + " 账号ID " + this.getClient().getAccID() + " 角色名 " + this.getName() + " 角色ID " + this.getId());
            FilePrinter.printError("MapleCharacter4.txt", e, "[角色存档]储存角色失败");
            FileoutputUtil.outError("logs/资料库异常.txt", e);
            FileoutputUtil.outError("logs/保存角色数据出错.txt", e);
        }
        return retValue;
    }

    private void deleteWhereCharacterId(Connection con, String sql) throws SQLException {
        deleteWhereCharacterId(con, sql, this.id);
    }

    public static void deleteWhereCharacterId(Connection con, String sql, int id) {
        try {
            PreparedStatement ps = con.prepareStatement(sql);
            ps.setInt(1, id);
            ps.executeUpdate();
            ps.close();
        } catch (Exception ex) {
            FileoutputUtil.outError("logs/保存角色数据出错7.txt", (Throwable) ex);
            FilePrinter.printError("MapleCharacter.txt", (Throwable) ex, "[deleteWhereCharacterId]");
        }
    }

    public void saveInventory(Connection con) {
        List<Pair<IItem, MapleInventoryType>> listing = (List<Pair<IItem, MapleInventoryType>>) new ArrayList();
        for (MapleInventory iv : this.inventory) {
            for (IItem item : iv.list()) {
                listing.add(new Pair(item, iv.getType()));
            }
        }
        if (con != null) {
            try {
                ItemLoader.INVENTORY.saveItems(listing, con, Integer.valueOf(this.id));
            } catch (SQLException ex) {
                FilePrinter.printError("MapleCharacter.txt", (Throwable) ex, "[saveInventory]");
                FileoutputUtil.outError("logs/保存角色数据出错8.txt", (Throwable) ex);
                FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) ex);
            }
        } else {
            try {
                ItemLoader.INVENTORY.saveItems(listing, Integer.valueOf(this.id));
            } catch (SQLException ex) {
                FilePrinter.printError("MapleCharacter.txt", (Throwable) ex, "[saveInventory]");
                FileoutputUtil.outError("logs/保存角色数据出错9.txt", (Throwable) ex);
                FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) ex);
            }
        }
    }

    public PlayerStats getStat() {
        return this.stats;
    }

    public PlayerRandomStream CRand() {
        return this.CRand;
    }

    public void QuestInfoPacket(MaplePacketLittleEndianWriter mplew) {
        mplew.writeShort(this.questinfo.size());
        for (Entry<Integer, String> q : this.questinfo.entrySet()) {
            mplew.writeShort(((Integer) q.getKey()).intValue());
            mplew.writeMapleAsciiString((q.getValue() == null) ? "" : ((String) q.getValue()));
        }
    }

    public void updateInfoQuest(int questid, String data) {
        this.questinfo.put(Integer.valueOf(questid), data);
        this.client.sendPacket(MaplePacketCreator.updateInfoQuest(questid, data));
    }

    public String getInfoQuest(int questid) {
        if (this.questinfo.containsKey(Integer.valueOf(questid))) {
            return (String) this.questinfo.get(Integer.valueOf(questid));
        }
        return "";
    }

    public int getNumQuest() {
        int i = 0;
        for (MapleQuestStatus q : this.quests.values()) {
            if (q.getStatus() == 2 && !q.isCustom()) {
                ++i;
            }
        }
        return i;
    }

    public byte getQuestStatus(int quest) {
        return this.getQuest(MapleQuest.getInstance(quest)).getStatus();
    }

    public MapleQuestStatus getQuest(MapleQuest quest) {
        if (!this.quests.containsKey(quest)) {
            return new MapleQuestStatus(quest, 0);
        }
        return (MapleQuestStatus) this.quests.get(quest);
    }

    public void setQuestAdd(MapleQuest quest, byte status, String customData) {
        if (!this.quests.containsKey(quest)) {
            MapleQuestStatus stat = new MapleQuestStatus(quest, (int) status);
            stat.setCustomData(customData);
            this.quests.put(quest, stat);
        }
    }

    public MapleQuestStatus getQuestNAdd(MapleQuest quest) {
        if (!this.quests.containsKey(quest)) {
            MapleQuestStatus status = new MapleQuestStatus(quest, 0);
            this.quests.put(quest, status);
            return status;
        }
        return (MapleQuestStatus) this.quests.get(quest);
    }

    public MapleQuestStatus getQuestNoAdd(MapleQuest quest) {
        return (MapleQuestStatus) this.quests.get(quest);
    }

    public MapleQuestStatus getQuestRemove(MapleQuest quest) {
        return (MapleQuestStatus) this.quests.remove(quest);
    }

    public void updateQuest(MapleQuestStatus quest) {
        this.updateQuest(quest, false);
    }

    public void updateQuest(MapleQuestStatus quest, boolean update) {
        this.quests.put(quest.getQuest(), quest);
        if (!quest.isCustom()) {
            this.client.sendPacket(MaplePacketCreator.updateQuest(quest));
            if (quest.getStatus() == 1 && !update) {
                this.client.sendPacket(MaplePacketCreator.updateQuestInfo(this, quest.getQuest().getId(), quest.getNpc(), (byte) 8));
            }
        }
    }

    public Map<Integer, String> getInfoQuest_Map() {
        return this.questinfo;
    }

    public Map<MapleQuest, MapleQuestStatus> getQuest_Map() {
        return this.quests;
    }

    public boolean isActiveBuffedValue(int skillid) {
        LinkedList<MapleBuffStatValueHolder> allBuffs = new LinkedList(this.effects.values());
        for (MapleBuffStatValueHolder mbsvh : allBuffs) {
            if (mbsvh.effect.isSkill() && mbsvh.effect.getSourceId() == skillid) {
                return true;
            }
        }
        return false;
    }

    public boolean isBuffedValue(int skillid) {
        LinkedList<MapleBuffStatValueHolder> allBuffs = new LinkedList(this.effects.values());
        for (MapleBuffStatValueHolder mbsvh : allBuffs) {
            if (mbsvh.effect.getSourceId() == skillid) {
                return true;
            }
        }
        return false;
    }

    public Integer getBuffedValue(MapleBuffStat effect) {
        MapleBuffStatValueHolder mbsvh = (MapleBuffStatValueHolder) this.effects.get(effect);
        return (mbsvh == null) ? null : Integer.valueOf(mbsvh.value);
    }

    public boolean hasBuffedValue(MapleBuffStat effect) {
        return this.getBuffedValue(effect) != null;
    }

    public Integer getBuffedSkill_X(MapleBuffStat effect) {
        MapleBuffStatValueHolder mbsvh = (MapleBuffStatValueHolder) this.effects.get(effect);
        if (mbsvh == null) {
            return null;
        }
        return Integer.valueOf(mbsvh.effect.getX());
    }

    public Integer getBuffedSkill_Y(MapleBuffStat effect) {
        MapleBuffStatValueHolder mbsvh = (MapleBuffStatValueHolder) this.effects.get(effect);
        if (mbsvh == null) {
            return null;
        }
        return Integer.valueOf(mbsvh.effect.getY());
    }

    public boolean isBuffFrom(MapleBuffStat stat, ISkill skill) {
        MapleBuffStatValueHolder mbsvh = (MapleBuffStatValueHolder) this.effects.get(stat);
        return mbsvh != null && mbsvh.effect.isSkill() && mbsvh.effect.getSourceId() == skill.getId();
    }

    public boolean changeFace(short item, int color) {
        int newFace = this.face / 1000 * 1000 + color + this.face % 10;
        if (!MapleItemInformationProvider.getInstance().faceExists(newFace)) {
            newFace = this.face;
            this.gainItem((int) item, 1);
        } else {
            this.face = newFace;
            this.updateSingleStat(MapleStat.FACE, newFace);
            this.equipChanged();
        }
        return MapleItemInformationProvider.faceLists.containsKey(Integer.valueOf(color));
    }

    public int getBuffSource(MapleBuffStat stat) {
        MapleBuffStatValueHolder mbsvh = (MapleBuffStatValueHolder) this.effects.get(stat);
        return (mbsvh == null) ? -1 : mbsvh.effect.getSourceId();
    }

    public int getItemQuantity(int itemid, boolean checkEquipped) {
        int possesed = this.inventory[GameConstants.getInventoryType(itemid).ordinal()].countById(itemid);
        if (checkEquipped) {
            possesed += this.inventory[MapleInventoryType.EQUIPPED.ordinal()].countById(itemid);
        }
        return possesed;
    }

    public void setBuffedValue(MapleBuffStat effect, int value) {
        MapleBuffStatValueHolder mbsvh = (MapleBuffStatValueHolder) this.effects.get(effect);
        if (mbsvh == null) {
            return;
        }
        mbsvh.value = value;
    }

    public Long getBuffedStarttime(MapleBuffStat effect) {
        MapleBuffStatValueHolder mbsvh = (MapleBuffStatValueHolder) this.effects.get(effect);
        return (mbsvh == null) ? null : Long.valueOf(mbsvh.startTime);
    }

    public MapleStatEffect getStatForBuff(MapleBuffStat effect) {
        MapleBuffStatValueHolder mbsvh = (MapleBuffStatValueHolder) this.effects.get(effect);
        return (mbsvh == null) ? null : mbsvh.effect;
    }

    public void doRecovery() {
        MapleStatEffect bloodEffect = this.getStatForBuff(MapleBuffStat.RECOVERY);
        if (bloodEffect != null) {
            this.prepareRecovery();
            if (this.stats.getHp() >= this.stats.getCurrentMaxHp()) {
                this.cancelEffectFromBuffStat(MapleBuffStat.RECOVERY);
            } else {
                this.healHP(bloodEffect.getX(), true);
            }
        }
    }

    public boolean canRecover(long now) {
        return this.lastRecoveryTime > 0L && this.lastRecoveryTime + 5000L < now;
    }

    private void prepareRecovery() {
        this.lastRecoveryTime = System.currentTimeMillis();
    }

    private void prepareDragonBlood(MapleStatEffect bloodEffect) {
        if (this.dragonBloodSchedule != null) {
            this.dragonBloodSchedule.cancel(false);
        }
        this.dragonBloodSchedule = BuffTimer.getInstance().register((Runnable) new Runnable() {
            @Override
            public void run() {
                if (MapleCharacter.this.stats.getHp() - bloodEffect.getX() > 1) {
                    MapleCharacter.this.cancelBuffStats(MapleBuffStat.DRAGONBLOOD);
                } else {
                    MapleCharacter.this.addHP(-bloodEffect.getX());
                    MapleCharacter.this.client.sendPacket(MaplePacketCreator.showOwnBuffEffect(bloodEffect.getSourceId(), 5));
                    MapleCharacter.this.map.broadcastMessage(MapleCharacter.this, MaplePacketCreator.showBuffeffect(MapleCharacter.this.getId(), bloodEffect.getSourceId(), 5), false);
                }
            }
        }, 4000L, 4000L);
    }

    public void startMapTimeLimitTask(int time, MapleMap to) {
        this.client.sendPacket(MaplePacketCreator.getClock(time));
        time *= 1000;
        this.mapTimeLimitTask = MapTimer.getInstance().register((Runnable) new Runnable() {
            @Override
            public void run() {
                MapleCharacter.this.changeMap(to, to.getPortal(0));
            }
        }, (long) time, (long) time);
    }

    public void startFishingTask(boolean VIP) {
        try {
            int time = GameConstants.getFishingTime(VIP, this.isGM());
            this.cancelFishingTask();
            this.fishing = EtcTimer.getInstance().register((Runnable) new Runnable() {
                @Override
                public void run() {
                    boolean expMulti = MapleCharacter.this.haveItem(2300001, 1, false, true);
                    if (!expMulti && !MapleCharacter.this.haveItem(2300000, 1, false, true)) {
                        MapleCharacter.this.cancelFishingTask();
                        return;
                    }
                    MapleInventoryManipulator.removeById(MapleCharacter.this.client, MapleInventoryType.USE, expMulti ? 2300001 : 2300000, 1, false, false);
                    int rewardType = FishingRewardFactory.getInstance().getNextRewardType();
                    switch (rewardType) {
                        case 0: {
                            int money = Randomizer.rand(expMulti ? 15 : 10, expMulti ? 3000 : 1000);
                            MapleCharacter.this.gainMeso(money, true);
                            MapleCharacter.this.client.sendPacket(UIPacket.fishingUpdate((byte) 1, money));
                            break;
                        }
                        case 1: {
                            int experi = Randomizer.nextInt(Math.abs(GameConstants.getExpNeededForLevel((int) MapleCharacter.this.level) / 800) + 1);
                            MapleCharacter.this.gainExp(expMulti ? (experi * 3 / 2) : experi, true, false, true);
                            MapleCharacter.this.client.sendPacket(UIPacket.fishingUpdate((byte) 2, experi));
                            break;
                        }
                        default: {
                            int gl = Randomizer.nextInt(2);
                            if (gl == 1) {
                                FishingReward item = FishingRewardFactory.getInstance().getNextRewardItemId();
                                if (item != null) {
                                    if (!MapleInventoryManipulator.checkSpace(MapleCharacter.this.client, item.getItemId(), 1, MapleCharacter.this.getName())) {
                                        MapleCharacter.this.client.sendPacket(MaplePacketCreator.serverNotice(5, "你的背包已满"));
                                        MapleCharacter.this.cancelFishingTask();
                                        return;
                                    }
                                    MapleInventoryManipulator.addById(MapleCharacter.this.client, item.getItemId(), (short) 1, GameConstants.isChair(item.getItemId()) ? MapleCharacter.this.getName() : null, null, (long) item.getExpiration());
                                    MapleCharacter.this.client.sendPacket(UIPacket.fishingUpdate((byte) 0, item.getItemId()));
                                }
                                break;
                            }
                            int moneya = Randomizer.rand(expMulti ? 15 : 10, expMulti ? 3000 : 1000);
                            MapleCharacter.this.gainMeso(moneya, true);
                            MapleCharacter.this.client.sendPacket(UIPacket.fishingUpdate((byte) 1, moneya));
                            break;
                        }
                    }
                    MapleCharacter.this.map.broadcastMessage(UIPacket.fishingCaught(MapleCharacter.this.id));
                }
            }, (long) time, (long) time);
        } catch (RejectedExecutionException ex) {
        }
    }

    public void cancelMapTimeLimitTask() {
        if (this.mapTimeLimitTask != null) {
            this.mapTimeLimitTask.cancel(false);
        }
    }

    public void cancelFishingTask() {
        if (this.fishing != null && !this.fishing.isCancelled()) {
            this.fishing.cancel(false);
        }
    }

    public void registerEffect(MapleStatEffect effect, long starttime, ScheduledFuture<?> schedule, int from) {
        this.registerEffect(effect, starttime, schedule, effect.getStatups(), false, effect.getDuration(), from);
    }

    public void registerEffect(MapleStatEffect effect, long starttime, ScheduledFuture<?> schedule, List<Pair<MapleBuffStat, Integer>> statups, boolean silent, int localDuration, int cid) {
        if (effect.isHide() && this.isGM()) {
            this.hidden = true;
            this.map.broadcastNONGMMessage(this, MaplePacketCreator.removePlayerFromMap(this.getId()), false);
        } else if (effect.isDragonBlood()) {
            this.prepareDragonBlood(effect);
        } else if (effect.isBerserk()) {
            this.checkBerserk();
        } else if (effect.isMonsterRiding_()) {
            this.getMount().startSchedule();
        } else if (effect.isBeholder()) {
            this.prepareBeholderEffect();
        } else if (effect.isRecovery()) {
            this.prepareRecovery();
        } else if (GameConstants.isAran((int) this.getJob())) {
            int reduce = this.Aran_ReduceCombo(effect.getSourceId());
            if (reduce > 0) {
                this.setCombo(this.getCombo() - reduce);
            }
        }
        int clonez = 0;
        for (Pair<MapleBuffStat, Integer> statup : statups) {
            if (statup.getLeft() == MapleBuffStat.ILLUSION) {
                clonez = ((Integer) statup.getRight()).intValue();
            }
            int value = ((Integer) statup.getRight()).intValue();
            if (statup.getLeft() == MapleBuffStat.MONSTER_RIDING && effect.getSourceId() == 5221006 && this.battleshipHP <= 0) {
                this.battleshipHP = value;
            }
            MapleBuffStatValueHolder mbsvh = new MapleBuffStatValueHolder(effect, starttime, schedule, value, localDuration, cid, effect.getSourceId());
            this.effects.put(statup.getLeft(), mbsvh);
            this.skillID.put(Integer.valueOf(effect.getSourceId()), mbsvh);
        }
        if (clonez > 0) {
            int cloneSize = Math.max((int) this.getNumClones(), this.getCloneSize());
            if (clonez > cloneSize) {
                for (int i = 0; i < clonez - cloneSize; ++i) {
                    this.cloneLook();
                }
            }
        }
        this.stats.recalcLocalStats();
        if (this.getDebugMessage()) {
            for (Pair<MapleBuffStat, Integer> buf : statups) {
                this.dropMessage(6, "[系统提示]\u0010" + ((MapleBuffStat) buf.getLeft()).toString() + "(0x" + HexTool.toString(((MapleBuffStat) buf.getLeft()).getValue()) + ")");
            }
        }
    }

    public List<MapleBuffStat> getBuffStats(MapleStatEffect effect, long startTime) {
        List<MapleBuffStat> bstats = (List<MapleBuffStat>) new ArrayList();
        Map<MapleBuffStat, MapleBuffStatValueHolder> allBuffs = new EnumMap(this.effects);
        for (Entry<MapleBuffStat, MapleBuffStatValueHolder> stateffect : allBuffs.entrySet()) {
            MapleBuffStatValueHolder mbsvh = (MapleBuffStatValueHolder) stateffect.getValue();
            if (mbsvh.effect.sameSource(effect) && (startTime == -1L || startTime == mbsvh.startTime)) {
                bstats.add(stateffect.getKey());
            }
        }
        return bstats;
    }

    public List<MapleBuffStat> getBuffStatsFromStatEffect(MapleStatEffect effect, long startTime) {
        List<MapleBuffStat> bstats = (List<MapleBuffStat>) new ArrayList();
        Map<MapleBuffStat, MapleBuffStatValueHolder> allBuffs = new EnumMap(this.effects);
        for (Entry<MapleBuffStat, MapleBuffStatValueHolder> stateffect : allBuffs.entrySet()) {
            MapleBuffStatValueHolder mbsvh = (MapleBuffStatValueHolder) stateffect.getValue();
            if (mbsvh.effect.sameSource(effect) && (startTime == -1L || startTime == mbsvh.startTime)) {
                bstats.add(stateffect.getKey());
                this.skillID.put(Integer.valueOf(effect.getSourceId()), mbsvh);
            }
        }
        return bstats;
    }

    private boolean deregisterBuffStats(List<MapleBuffStat> stats) {
        boolean clonez = false;
        List<MapleBuffStatValueHolder> effectsToCancel = (List<MapleBuffStatValueHolder>) new ArrayList(stats.size());
        for (MapleBuffStat stat : stats) {
            MapleBuffStatValueHolder mbsvh = (MapleBuffStatValueHolder) this.effects.remove(stat);
            if (mbsvh != null) {
                this.skillID.remove(Integer.valueOf(mbsvh.effect.getSourceId()));
                boolean addMbsvh = true;
                for (MapleBuffStatValueHolder contained : effectsToCancel) {
                    if (mbsvh.startTime == contained.startTime && contained.effect == mbsvh.effect) {
                        addMbsvh = false;
                    }
                }
                if (addMbsvh) {
                    effectsToCancel.add(mbsvh);
                }
                if (stat == MapleBuffStat.SUMMON || stat == MapleBuffStat.PUPPET) {
                    int summonId = mbsvh.effect.getSourceId();
                    MapleSummon summon = (MapleSummon) this.summons.get(Integer.valueOf(summonId));
                    if (summon == null) {
                        continue;
                    }
                    this.map.broadcastMessage(MaplePacketCreator.removeSummon(summon, true));
                    this.map.removeMapObject((MapleMapObject) summon);
                    this.removeVisibleMapObject((MapleMapObject) summon);
                    this.summons.remove(Integer.valueOf(summonId));
                    if (summon.getSkill() != 1321007) {
                        continue;
                    }
                    if (this.beholderHealingSchedule != null) {
                        this.beholderHealingSchedule.cancel(false);
                        this.beholderHealingSchedule = null;
                    }
                    if (this.beholderBuffSchedule == null) {
                        continue;
                    }
                    this.beholderBuffSchedule.cancel(false);
                    this.beholderBuffSchedule = null;
                } else if (stat == MapleBuffStat.DRAGONBLOOD) {
                    if (this.dragonBloodSchedule == null) {
                        continue;
                    }
                    this.dragonBloodSchedule.cancel(false);
                    this.dragonBloodSchedule = null;
                } else if (stat == MapleBuffStat.RECOVERY) {
                    this.lastRecoveryTime = 0L;
                } else {
                    if (stat != MapleBuffStat.ILLUSION) {
                        continue;
                    }
                    this.disposeClones();
                    clonez = true;
                }
            }
        }
        for (MapleBuffStatValueHolder cancelEffectCancelTasks : effectsToCancel) {
            if (this.getBuffStatsFromStatEffect(cancelEffectCancelTasks.effect, cancelEffectCancelTasks.startTime).isEmpty() && cancelEffectCancelTasks.schedule != null) {
                cancelEffectCancelTasks.schedule.cancel(false);
            }
        }
        return clonez;
    }

    public void cancelEffect(MapleStatEffect effect, boolean overwrite, long startTime) {
        if (this != null && effect != null) {
            this.cancelEffect(effect, overwrite, startTime, effect.getStatups());
        }
    }

    public void cancelEffect(MapleStatEffect effect, boolean overwrite, long startTime, List<Pair<MapleBuffStat, Integer>> statups) {
        List<MapleBuffStat> buffstats;
        if (!overwrite) {
            buffstats = this.getBuffStats(effect, startTime);
        } else {
            buffstats = (List<MapleBuffStat>) new ArrayList(statups.size());
            for (Pair<MapleBuffStat, Integer> statup : statups) {
                buffstats.add(statup.getLeft());
            }
        }
        if (buffstats.size() <= 0) {
            return;
        }
        boolean clonez = this.deregisterBuffStats(buffstats);
        if (effect.isMagicDoor()) {
            if (!this.getDoors().isEmpty()) {
                this.removeDoor();
                this.silentPartyUpdate();
            }
        } else if (effect.isMonsterRiding_()) {
            this.getMount().cancelSchedule();
        } else if (effect.isAranCombo()) {
            this.combo = 0;
        }
        if (!overwrite) {
            this.cancelPlayerBuffs(buffstats);
            if (this.isGM() && effect.isHide() && this.client.getChannelServer().getPlayerStorage().getCharacterById(this.getId()) != null) {
                this.hidden = false;
                this.map.broadcastMessage(this, MaplePacketCreator.spawnPlayerMapobject(this), false);
                for (MaplePet pet : this.pets) {
                    if (pet.getSummoned()) {
                        this.map.broadcastMessage(this, PetPacket.showPet(this, pet, false, false), false);
                    }
                }
                for (WeakReference<MapleCharacter> chr : this.clones) {
                    if (chr.get() != null) {
                        this.map.broadcastMessage((MapleCharacter) chr.get(), MaplePacketCreator.spawnPlayerMapobject((MapleCharacter) chr.get()), false);
                    }
                }
            }
        }
        if (!clonez) {
            for (WeakReference<MapleCharacter> chr : this.clones) {
                if (chr.get() != null) {
                    ((MapleCharacter) chr.get()).cancelEffect(effect, overwrite, startTime);
                }
            }
        }
        if (this.getDebugMessage()) {
            this.dropMessage("取消技能 - " + effect.getName() + "(" + effect.getSourceId() + ")");
        }
    }

    public void cancelBuffStats(MapleBuffStat... stat) {
        List<MapleBuffStat> buffStatList = Arrays.asList(stat);
        this.deregisterBuffStats(buffStatList);
        this.cancelPlayerBuffs(buffStatList);
    }

    public void cancelEffectFromBuffStat(MapleBuffStat stat) {
        if (this.effects.get(stat) != null) {
            this.cancelEffect(((MapleBuffStatValueHolder) this.effects.get(stat)).effect, false, -1L);
        }
    }

    private void cancelPlayerBuffs(List<MapleBuffStat> buffstats) {
        MapleBuffStatValueHolder mbsvh = (MapleBuffStatValueHolder) this.effects.remove(buffstats);
        boolean write = this.client.getChannelServer().getPlayerStorage().getCharacterById(this.getId()) != null;
        if (buffstats.contains(MapleBuffStat.HOMING_BEACON)) {
            if (write) {
                this.client.sendPacket(MaplePacketCreator.cancelHoming());
            }
        } else {
            if (write) {
                this.stats.recalcLocalStats();
            }
            this.client.sendPacket(MaplePacketCreator.cancelBuff(buffstats));
            this.map.broadcastMessage(this, MaplePacketCreator.cancelForeignBuff(this.getId(), buffstats), false);
        }
    }

    public void dispel() {
        if (!this.isHidden()) {
            LinkedList<MapleBuffStatValueHolder> allBuffs = new LinkedList(this.effects.values());
            for (MapleBuffStatValueHolder mbsvh : allBuffs) {
                if (mbsvh.effect.isSkill() && mbsvh.schedule != null && !mbsvh.effect.isMorph() && !mbsvh.effect.isEnergyCharge()) {
                    this.cancelEffect(mbsvh.effect, false, mbsvh.startTime);
                }
            }
        }
    }

    public void dispelSkill(int skillid) {
        LinkedList<MapleBuffStatValueHolder> allBuffs = new LinkedList(this.effects.values());
        for (MapleBuffStatValueHolder mbsvh : allBuffs) {
            if (skillid == 0) {
                if (mbsvh.effect.isSkill() && (mbsvh.effect.getSourceId() == 4331003 || mbsvh.effect.getSourceId() == 4331002 || mbsvh.effect.getSourceId() == 4341002 || mbsvh.effect.getSourceId() == 22131001 || mbsvh.effect.getSourceId() == 1321007 || mbsvh.effect.getSourceId() == 2121005 || mbsvh.effect.getSourceId() == 2221005 || mbsvh.effect.getSourceId() == 2311006 || mbsvh.effect.getSourceId() == 2321003 || mbsvh.effect.getSourceId() == 3111002 || mbsvh.effect.getSourceId() == 3111005 || mbsvh.effect.getSourceId() == 3211002 || mbsvh.effect.getSourceId() == 3211005 || mbsvh.effect.getSourceId() == 4111002)) {
                    this.cancelEffect(mbsvh.effect, false, mbsvh.startTime);
                    break;
                }
                continue;
            } else {
                if (mbsvh.effect.isSkill() && mbsvh.effect.getSourceId() == skillid) {
                    this.cancelEffect(mbsvh.effect, false, mbsvh.startTime);
                    break;
                }
                continue;
            }
        }
    }

    public void dispelBuff(int skillid) {
        LinkedList<MapleBuffStatValueHolder> allBuffs = new LinkedList(this.effects.values());
        for (MapleBuffStatValueHolder mbsvh : allBuffs) {
            if (mbsvh.effect.getSourceId() == skillid) {
                this.cancelEffect(mbsvh.effect, false, mbsvh.startTime);
                break;
            }
        }
    }

    public void cancelAllBuffs_() {
        this.effects.clear();
    }

    public void cancelAllSkillID() {
        this.skillID.clear();
    }

    public void cancelAllBuffs() {
        LinkedList<MapleBuffStatValueHolder> allBuffs = new LinkedList(this.effects.values());
        for (MapleBuffStatValueHolder mbsvh : allBuffs) {
            this.cancelEffect(mbsvh.effect, false, mbsvh.startTime);
        }
    }

    public void cancelMorphs() {
        LinkedList<MapleBuffStatValueHolder> allBuffs = new LinkedList(this.effects.values());
        for (MapleBuffStatValueHolder mbsvh : allBuffs) {
            switch (mbsvh.effect.getSourceId()) {
                case 5111005:
                case 5121003:
                case 13111005:
                case 15111002: {
                    return;
                }
                default: {
                    if (!mbsvh.effect.isMorph()) {
                        continue;
                    }
                    this.cancelEffect(mbsvh.effect, false, mbsvh.startTime);
                    continue;
                }
            }
        }
    }

    public int getMorphState() {
        LinkedList<MapleBuffStatValueHolder> allBuffs = new LinkedList(this.effects.values());
        for (MapleBuffStatValueHolder mbsvh : allBuffs) {
            if (mbsvh.effect.isMorph()) {
                return mbsvh.effect.getSourceId();
            }
        }
        return -1;
    }

    public void silentGiveBuffs(List<PlayerBuffValueHolder> buffs) {
        if (buffs == null) {
            return;
        }
        for (PlayerBuffValueHolder mbsvh : buffs) {
            mbsvh.effect.silentApplyBuff(this, mbsvh.startTime, mbsvh.localDuration, mbsvh.statup, mbsvh.cid);
        }
    }

    public List<PlayerBuffValueHolder> getAllBuffs() {
        List<PlayerBuffValueHolder> ret = (List<PlayerBuffValueHolder>) new ArrayList();
        Map<Pair<Integer, Byte>, Integer> alreadyDone = (Map<Pair<Integer, Byte>, Integer>) new HashMap();
        LinkedList<Entry<MapleBuffStat, MapleBuffStatValueHolder>> allBuffs = new LinkedList(this.effects.entrySet());
        for (Entry<MapleBuffStat, MapleBuffStatValueHolder> mbsvh : allBuffs) {
            Pair<Integer, Byte> key = new Pair(Integer.valueOf(((MapleBuffStatValueHolder) mbsvh.getValue()).effect.getSourceId()), Byte.valueOf(((MapleBuffStatValueHolder) mbsvh.getValue()).effect.getLevel()));
            if (alreadyDone.containsKey(key)) {
                ((PlayerBuffValueHolder) ret.get(((Integer) alreadyDone.get(key)).intValue())).statup.add(new Pair(mbsvh.getKey(), Integer.valueOf(((MapleBuffStatValueHolder) mbsvh.getValue()).value)));
            } else {
                alreadyDone.put(key, Integer.valueOf(ret.size()));
                ArrayList<Pair<MapleBuffStat, Integer>> list = (ArrayList<Pair<MapleBuffStat, Integer>>) new ArrayList();
                list.add(new Pair(mbsvh.getKey(), Integer.valueOf(((MapleBuffStatValueHolder) mbsvh.getValue()).value)));
                ret.add(new PlayerBuffValueHolder(((MapleBuffStatValueHolder) mbsvh.getValue()).startTime, ((MapleBuffStatValueHolder) mbsvh.getValue()).effect, (List<Pair<MapleBuffStat, Integer>>) list, ((MapleBuffStatValueHolder) mbsvh.getValue()).localDuration, ((MapleBuffStatValueHolder) mbsvh.getValue()).cid));
            }
        }
        return ret;
    }

    public void cancelMagicDoor() {
        LinkedList<MapleBuffStatValueHolder> allBuffs = new LinkedList(this.effects.values());
        for (MapleBuffStatValueHolder mbsvh : allBuffs) {
            if (mbsvh.effect.isMagicDoor()) {
                this.cancelEffect(mbsvh.effect, false, mbsvh.startTime);
                break;
            }
        }
    }

    public int getSkillLevel(int skillid) {
        return this.getSkillLevel(SkillFactory.getSkill(skillid));
    }

    public void handleEnergyCharge(int skillid, int targets) {
        ISkill echskill = SkillFactory.getSkill(skillid);
        byte skilllevel = this.getSkillLevel(echskill);
        if (skilllevel > 0) {
            MapleStatEffect echeff = echskill.getEffect((int) skilllevel);
            if (targets > 0) {
                if (this.getBuffedValue(MapleBuffStat.ENERGY_CHARGE) == null) {
                    echeff.applyEnergyBuff(this, true);
                } else {
                    Integer energyLevel = this.getBuffedValue(MapleBuffStat.ENERGY_CHARGE);
                    if (energyLevel.intValue() < 10000) {
                        energyLevel = Integer.valueOf(energyLevel.intValue() + echeff.getX() * targets);
                        this.client.sendPacket(MaplePacketCreator.showOwnBuffEffect(skillid, 2));
                        this.map.broadcastMessage(this, MaplePacketCreator.showBuffeffect(this.id, skillid, 2), false);
                        if (energyLevel.intValue() >= 10000) {
                            energyLevel = Integer.valueOf(10000);
                        }
                        this.client.sendPacket(MaplePacketCreator.giveEnergyChargeTest(energyLevel.intValue(), echeff.getDuration() / 1000));
                        this.setBuffedValue(MapleBuffStat.ENERGY_CHARGE, energyLevel.intValue());
                    } else if (energyLevel.intValue() == 10000) {
                        echeff.applyEnergyBuff(this, false);
                        this.setBuffedValue(MapleBuffStat.ENERGY_CHARGE, 10001);
                    }
                }
            }
        }
    }

    public void handleBattleshipHP(int damage) {
        if (this.isActiveBuffedValue(5221006)) {
            this.battleshipHP -= damage;
            if (this.battleshipHP <= 0) {
                this.battleshipHP = 0;
                MapleStatEffect effect = this.getStatForBuff(MapleBuffStat.MONSTER_RIDING);
                this.client.sendPacket(MaplePacketCreator.skillCooldown(5221006, effect.getCooldown()));
                this.addCooldown(5221006, System.currentTimeMillis(), (long) (effect.getCooldown() * 1000));
                this.dispelSkill(5221006);
            }
        }
    }

    public void handleOrbgain() {
        int orbcount = this.getBuffedValue(MapleBuffStat.COMBO).intValue();
        ISkill theCombol = null;
        ISkill advcombo = null;
        switch (this.getJob()) {
            case 1110:
            case 1111:
            case 1112: {
                theCombol = SkillFactory.getSkill(11111001);
                advcombo = SkillFactory.getSkill(11110005);
                break;
            }
            default: {
                theCombol = SkillFactory.getSkill(1111002);
                advcombo = SkillFactory.getSkill(1120003);
                break;
            }
        }
        int advComboSkillLevel = this.getSkillLevel(advcombo);
        MapleStatEffect ceffect;
        if (advComboSkillLevel > 0) {
            ceffect = advcombo.getEffect(advComboSkillLevel);
        } else {
            if (this.getSkillLevel(theCombol) <= 0) {
                return;
            }
            ceffect = theCombol.getEffect((int) this.getSkillLevel(theCombol));
        }
        if (orbcount < ceffect.getX() + 1) {
            int neworbcount = orbcount + 1;
            if (advComboSkillLevel > 0 && ceffect.makeChanceResult() && neworbcount < ceffect.getX() + 1) {
                ++neworbcount;
            }
            List<Pair<MapleBuffStat, Integer>> stat = Collections.singletonList(new Pair(MapleBuffStat.COMBO, Integer.valueOf(neworbcount)));
            this.setBuffedValue(MapleBuffStat.COMBO, neworbcount);
            int duration = ceffect.getDuration();
            duration += (int) (this.getBuffedStarttime(MapleBuffStat.COMBO).longValue() - System.currentTimeMillis());
            this.client.sendPacket(MaplePacketCreator.giveBuff(theCombol.getId(), duration, stat, ceffect));
            this.map.broadcastMessage(this, MaplePacketCreator.giveForeignBuff(this.getId(), stat, ceffect), false);
        }
    }

    public void handleOrbconsume() {
        ISkill theCombol = null;
        switch (this.getJob()) {
            case 1110:
            case 1111:
            case 1112: {
                theCombol = SkillFactory.getSkill(11111001);
                break;
            }
            default: {
                theCombol = SkillFactory.getSkill(1111002);
                break;
            }
        }
        if (this.getSkillLevel(theCombol) <= 0) {
            return;
        }
        MapleStatEffect ceffect = this.getStatForBuff(MapleBuffStat.COMBO);
        if (ceffect == null) {
            return;
        }
        List<Pair<MapleBuffStat, Integer>> stat = Collections.singletonList(new Pair(MapleBuffStat.COMBO, Integer.valueOf(1)));
        this.setBuffedValue(MapleBuffStat.COMBO, 1);
        int duration = ceffect.getDuration();
        duration += (int) (this.getBuffedStarttime(MapleBuffStat.COMBO).longValue() - System.currentTimeMillis());
        this.client.sendPacket(MaplePacketCreator.giveBuff(theCombol.getId(), duration, stat, ceffect));
        this.map.broadcastMessage(this, MaplePacketCreator.giveForeignBuff(this.getId(), stat, ceffect), false);
    }

    public void silentEnforceMaxHpMp() {
        this.stats.setMp((int) this.stats.getMp());
        this.stats.setHp((int) this.stats.getHp(), true);
    }

    public void enforceMaxHpMp() {
        Map<MapleStat, Integer> statups = new EnumMap(MapleStat.class);
        if (this.stats.getMp() > this.stats.getCurrentMaxMp()) {
            this.stats.setMp((int) this.stats.getMp());
            statups.put(MapleStat.MP, Integer.valueOf((int) this.stats.getMp()));
        }
        if (this.stats.getHp() > this.stats.getCurrentMaxHp()) {
            this.stats.setHp((int) this.stats.getHp());
            statups.put(MapleStat.HP, Integer.valueOf((int) this.stats.getHp()));
        }
        if (statups.size() > 0) {
            this.client.sendPacket(MaplePacketCreator.updatePlayerStats(statups, this));
        }
    }

    public MapleMap getMap() {
        return this.map;
    }

    public MonsterBook getMonsterBook() {
        return this.monsterbook;
    }

    public void setMap(MapleMap newmap) {
        this.map = newmap;
    }

    public void setMap(int PmapId) {
        this.mapid = PmapId;
    }

    public int getMapId() {
        if (this.map != null) {
            return this.map.getId();
        }
        return this.mapid;
    }

    public byte getInitialSpawnpoint() {
        return this.initialSpawnPoint;
    }

    public int getId() {
        return this.id;
    }

    public String getName() {
        return this.name;
    }

    public boolean canHold(int itemid) {
        return this.getInventory(GameConstants.getInventoryType(itemid)).getNextFreeSlot() > -1;
    }

    public String getBlessOfFairyOrigin() {
        return this.BlessOfFairy_Origin;
    }

    public short getLevel() {
        if (this.level < 1) {
            this.level = 1;
        }
        return this.level;
    }

    public short getFame() {
        return this.fame;
    }

    public int getDojo() {
        return this.dojo;
    }

    public int getDojoRecord() {
        return this.dojoRecord;
    }

    public int getFallCounter() {
        return this.fallcounter;
    }

    public MapleClient getClient() {
        return this.client;
    }

    public void setClient(MapleClient client) {
        this.client = client;
    }

    public int getExp() {
        return this.exp;
    }

    public short getRemainingAp() {
        return this.remainingAp;
    }

    public int getRemainingSp() {
        return this.remainingSp[GameConstants.getSkillBook((int) this.job)];
    }

    public int getRemainingSp(int skillbook) {
        return this.remainingSp[skillbook];
    }

    public int[] getRemainingSps() {
        return this.remainingSp;
    }

    public int getRemainingSpSize() {
        int ret = 0;
        for (int i = 0; i < this.remainingSp.length; ++i) {
            if (this.remainingSp[i] > 0) {
                ++ret;
            }
        }
        return ret;
    }

    public short getHpMpApUsed() {
        return this.hpmpApUsed;
    }

    public boolean isHidden() {
        return this.hidden;
    }

    public void setHpMpApUsed(short hpApUsed) {
        this.hpmpApUsed = hpApUsed;
    }

    public byte getSkinColor() {
        return this.skinColor;
    }

    public void setSkinColor(byte skinColor) {
        this.skinColor = skinColor;
    }

    public short getJob() {
        return this.job;
    }

    public byte getGender() {
        return this.gender;
    }

    public int getHair() {
        return this.hair;
    }

    public int getFace() {
        return this.face;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void setExp(int exp) {
        this.exp = exp;
    }

    public void setHair(int hair) {
        this.hair = hair;
    }

    public void setFace(int face) {
        this.face = face;
    }

    public void setFame(short fame) {
        this.fame = fame;
    }

    public void setDojo(int dojo) {
        this.dojo = dojo;
    }

    public void setDojoRecord(boolean reset) {
        if (reset) {
            this.dojo = 0;
            this.dojoRecord = 0;
        } else {
            ++this.dojoRecord;
        }
    }

    public void setFallCounter(int fallcounter) {
        this.fallcounter = fallcounter;
    }

    public Point getOldPosition() {
        return this.old;
    }

    public void setOldPosition(Point x) {
        this.old = x;
    }

    public void setRemainingAp(short remainingAp) {
        this.remainingAp = remainingAp;
    }

    public void setRemainingSp(int remainingSp) {
        this.remainingSp[GameConstants.getSkillBook((int) this.job)] = remainingSp;
    }

    public void setRemainingSp(int remainingSp, int skillbook) {
        this.remainingSp[skillbook] = remainingSp;
    }

    public void setGender(byte gender) {
        this.gender = gender;
    }

    public void setInvincible(boolean invinc) {
        this.invincible = invinc;
    }

    public boolean isInvincible() {
        return this.invincible;
    }

    public CheatTracker getCheatTracker() {
        return this.anticheat;
    }

    public MapleLieDetector getAntiMacro() {
        return this.antiMacro;
    }

    public void startLieDetector(boolean isItem) {
        if ((this.getMapId() < 910000000 || this.getMapId() > 910000022) && this.getMapId() != 800040410 && !GameConstants.isFishingMap(this.getMapId()) && this.getMap().getReturnMapId() != this.getMapId()) {
            if (this.getAntiMacro().isPassed()) {
                this.getAntiMacro().setPassed(false);
            }
            if (!this.getAntiMacro().inProgress()) {
                this.getAntiMacro().startLieDetector(this.getName(), isItem, false);
            }
        }
    }

    public BuddyList getBuddylist() {
        return this.buddylist;
    }

    public void addFame(int famechange) {
        this.fame += (short) famechange;
        this.updateFame();
    }

    public void changeMap(int mapid) {
        MapleMap target = this.client.getChannelServer().getMapFactory().getMap(mapid);
        this.changeMap(target, target.getPortal(0));
    }

    public void changeMapBanish(int mapid, String portal, String msg) {
        this.dropMessage(5, msg);
        MapleMap target = this.client.getChannelServer().getMapFactory().getMap(mapid);
        this.changeMap(target, target.getPortal(portal));
    }

    public void changeMap(MapleMap to, Point pos) {
        this.changeMapInternal(to, pos, MaplePacketCreator.getWarpToMap(to, 129, this), null);
    }

    public void changeMap(MapleMap to, MaplePortal pto) {
        this.changeMapInternal(to, pto.getPosition(), MaplePacketCreator.getWarpToMap(to, pto.getId(), this), null);
    }

    public void changeMapPortal(MapleMap to, MaplePortal pto) {
        this.changeMapInternal(to, pto.getPosition(), MaplePacketCreator.getWarpToMap(to, pto.getId(), this), pto);
    }

    private void changeMapInternal(MapleMap to, Point pos, byte[] warpPacket, MaplePortal pto) {
        if (to == null) {
            return;
        }
        this.saveToDB(true, true);
        if (pto != null && GameConstants.isNotTo(to.getId(), pto.getName())) {
            if (this.getParty() == null || this.getParty().getMembers().size() == 1) {
                this.changeMap(211060000);
                return;
            }
            int cMap = this.getMapId();
            for (MaplePartyCharacter chr : this.getParty().getMembers()) {
                MapleCharacter curChar = this.getClient().getChannelServer().getPlayerStorage().getCharacterById(chr.getId());
                if (curChar != null && (curChar.getMapId() == cMap || curChar.getEventInstance() == this.getEventInstance())) {
                    curChar.changeMap(211060000);
                }
            }
            return;
        } else {
            if (this.getAntiMacro().inProgress()) {
                this.dropMessage(5, "被使用测谎仪时无法操作。");
                this.client.sendPacket(MaplePacketCreator.enableActions());
                return;
            }
            if (to.getId() != 105100300) {
                this.dispelBuff(2022536);
                this.dispelBuff(2022537);
            }
            if (to.getId() == 180000000 && this.getGMLevel() < 4) {
                this.changeMap(100000000);
                return;
            }
            int nowmapid = this.map.getId();
            if (this.eventInstance != null) {
                this.eventInstance.changedMap(this, to.getId());
            }
            if (this.getTrade() != null) {
                if (this.getTrade().getPartner() != null) {
                    MapleTrade local = this.getTrade();
                    MapleTrade partners = local.getPartner();
                    if (local.isLocked() && partners.isLocked()) {
                        this.client.getSession().write(MaplePacketCreator.enableActions());
                    } else {
                        MapleTrade.cancelTrade(this.getTrade(), this.getClient());
                    }
                } else {
                    MapleTrade.cancelTrade(this.getTrade(), this.client);
                }
            }
            boolean pyramid = this.pyramidSubway != null;
            if (this.map.getId() == nowmapid) {
                this.client.sendPacket(warpPacket);
                this.map.removePlayer(this);
                if (!this.isClone() && this.client.getChannelServer().getPlayerStorage().getCharacterById(this.getId()) != null) {
                    this.map = to;
                    this.setPosition(pos);
                    to.addPlayer(this);
                    this.stats.relocHeal();
                }
            }
            if (pyramid && this.pyramidSubway != null) {
                this.pyramidSubway.onChangeMap(this, to.getId());
            }
            if (Mushplotact.getStartState() && Mushplotact.getEggmap() == to.getId()) {
                this.client.getPlayer().dropMessage("蘑插辣的魔力源泉貌似就在附近了！！");
            }
            return;
        }
    }

    public void leaveMap() {
        this.visibleMapObjectsLock.writeLock().lock();
        try {
            for (MapleMonster mons : this.controlled) {
                if (mons != null) {
                    mons.setController(null);
                    mons.setControllerHasAggro(false);
                    mons.setControllerKnowsAboutAggro(false);
                    this.map.updateMonsterController(mons);
                }
            }
            this.controlled.clear();
            this.visibleMapObjects.clear();
        } finally {
            this.visibleMapObjectsLock.writeLock().unlock();
        }
        if (this.chair != 0) {
            this.cancelFishingTask();
            this.chair = 0;
        }
        if (this.getTrade() != null) {
            if (this.getTrade().getPartner() != null) {
                MapleTrade local = this.getTrade();
                MapleTrade partners = local.getPartner();
                if (local.isLocked() && partners.isLocked()) {
                    this.client.getSession().write(MaplePacketCreator.enableActions());
                } else {
                    MapleTrade.cancelTrade(this.getTrade(), this.getClient());
                }
            } else {
                MapleTrade.cancelTrade(this.getTrade(), this.client);
            }
        }
        this.cancelMapTimeLimitTask();
    }

    public void changeJob(int newJob) {
        try {
            this.updateSingleStat(MapleStat.JOB, newJob);
            boolean isEv = GameConstants.isEvan((int) this.job) || GameConstants.isResist((int) this.job);
            this.job = (short) newJob;
            if (newJob != 0 && newJob != 1000 && newJob != 2000 && newJob != 2001 && newJob != 3000) {
                if (isEv) {
                    int[] remainingSp = this.remainingSp;
                    int skillBook = GameConstants.getSkillBook(newJob);
                    remainingSp[skillBook] += 5;
                    this.client.getSession().write(UIPacket.getSPMsg((byte) 5, (short) newJob));
                } else {
                    int[] remainingSp2 = this.remainingSp;
                    int skillBook2 = GameConstants.getSkillBook(newJob);
                    ++remainingSp2[skillBook2];
                    if (newJob % 10 >= 2) {
                        int[] remainingSp3 = this.remainingSp;
                        int skillBook3 = GameConstants.getSkillBook(newJob);
                        remainingSp3[skillBook3] += 2;
                    }
                }
            }
            if (newJob > 0) {
                this.resetStatsByJob(true);
                if (this.getLevel() > ((newJob == 200) ? 8 : 10) && newJob % 100 == 0 && newJob % 1000 / 100 > 0) {
                    int[] remainingSp4 = this.remainingSp;
                    int skillBook4 = GameConstants.getSkillBook(newJob);
                    remainingSp4[skillBook4] += 3 * (this.getLevel() - ((newJob == 200) ? 8 : 10));
                }
            }
            this.client.sendPacket(MaplePacketCreator.updateSp(this, false));
            int maxhp = this.stats.getMaxHp();
            int maxmp = this.stats.getMaxMp();
            switch (this.job) {
                case 100:
                case 1100:
                case 2100: {
                    maxhp += Randomizer.rand(200, 250);
                    break;
                }
                case 200: {
                    maxmp += Randomizer.rand(100, 150);
                    break;
                }
                case 300:
                case 400:
                case 500: {
                    maxhp += Randomizer.rand(100, 150);
                    maxmp += Randomizer.rand(25, 50);
                    break;
                }
                case 110: {
                    maxhp += Randomizer.rand(300, 350);
                    break;
                }
                case 120:
                case 130:
                case 510:
                case 512:
                case 1110:
                case 2110: {
                    maxhp += Randomizer.rand(300, 350);
                    break;
                }
                case 210:
                case 220:
                case 230: {
                    maxmp += Randomizer.rand(400, 450);
                    break;
                }
                case 310:
                case 312:
                case 320:
                case 322:
                case 410:
                case 412:
                case 420:
                case 422:
                case 520:
                case 522:
                case 1310:
                case 1410: {
                    maxhp += Randomizer.rand(300, 350);
                    maxhp += Randomizer.rand(150, 200);
                    break;
                }
                case 800:
                case 900: {
                    maxhp += 30000;
                    maxhp += 30000;
                    maxmp += 30000;
                    maxmp += 30000;
                    break;
                }
            }
            if (maxhp >= 30000) {
                maxhp = 30000;
            }
            if (maxmp >= 30000) {
                maxmp = 30000;
            }
            this.stats.setMaxHp((short) maxhp);
            this.stats.setMaxMp((short) maxmp);
            this.stats.setHp((int) (short) maxhp);
            this.stats.setMp((int) (short) maxmp);
            Map<MapleStat, Integer> statup = new EnumMap(MapleStat.class);
            statup.put(MapleStat.MAXHP, Integer.valueOf(maxhp));
            statup.put(MapleStat.MAXMP, Integer.valueOf(maxmp));
            statup.put(MapleStat.HP, Integer.valueOf(maxhp));
            statup.put(MapleStat.MP, Integer.valueOf(maxmp));
            this.stats.recalcLocalStats();
            this.client.sendPacket(MaplePacketCreator.updatePlayerStats(statup, this));
            this.map.broadcastMessage(this, MaplePacketCreator.showForeignEffect(this.getId(), 9), false);
            this.silentPartyUpdate();
            this.guildUpdate();
            this.familyUpdate();
            this.baseSkills();
        } catch (Exception e) {
            FilePrinter.printError("MapleCharacter.txt", (Throwable) e);
        }
    }

    public void setPetAutoFood(boolean auto) {
        this.petAutoFood = auto;
    }

    public boolean isPetAutoFood() {
        return this.petAutoFood;
    }

    public void baseSkills() {
        if (GameConstants.getJobNumber((int) this.job) >= 3) {
            List<Integer> baseSkills = SkillFactory.getSkillsByJob((int) this.job);
            if (baseSkills != null) {
                Iterator<Integer> iterator = baseSkills.iterator();
                while (iterator.hasNext()) {
                    int i = ((Integer) iterator.next()).intValue();
                    ISkill skil = SkillFactory.getSkill(i);
                    if (skil != null && !skil.isInvisible() && skil.isFourthJob() && this.getSkillLevel(skil) <= 0 && this.getMasterLevel(skil) <= 0 && skil.getMasterLevel() > 0) {
                        this.changeSkillLevel(skil, (byte) 0, (byte) skil.getMasterLevel());
                    }
                }
            }
        }
    }

    public void gainAp(short ap) {
        this.remainingAp += ap;
        this.updateSingleStat(MapleStat.AVAILABLEAP, (int) this.remainingAp);
    }

    public void gainSP(int sp) {
        int[] remainingSp = this.remainingSp;
        int skillBook = GameConstants.getSkillBook((int) this.job);
        remainingSp[skillBook] += sp;
        this.client.sendPacket(MaplePacketCreator.updateSp(this, false));
        this.client.sendPacket(UIPacket.getSPMsg((byte) sp, this.job));
    }

    public void gainSP(int sp, int skillbook) {
        int[] remainingSp = this.remainingSp;
        remainingSp[skillbook] += sp;
        this.client.sendPacket(MaplePacketCreator.updateSp(this, false));
        this.client.sendPacket(UIPacket.getSPMsg((byte) sp, this.job));
    }

    public void resetAPSP() {
        for (int i = 0; i < this.remainingSp.length; ++i) {
            this.remainingSp[i] = 0;
        }
        this.client.sendPacket(MaplePacketCreator.updateSp(this, false));
        this.gainAp((short) (-this.remainingAp));
    }

    public void changeSkillLevel(ISkill skill, byte newLevel, byte newMasterlevel) {
        if (skill == null) {
            return;
        }
        this.changeSkillLevel(skill, newLevel, newMasterlevel, skill.isTimeLimited() ? (System.currentTimeMillis() + 2592000000L) : -1L);
    }

    public void changeSkillLevel(ISkill skill, byte newLevel, byte newMasterlevel, long expiration) {
        if (skill == null || (!GameConstants.isApplicableSkill(skill.getId()) && !GameConstants.isApplicableSkill_(skill.getId()))) {
            return;
        }
        this.client.sendPacket(MaplePacketCreator.updateSkill(skill.getId(), (int) newLevel, (int) newMasterlevel, expiration));
        if (newLevel == 0 && newMasterlevel == 0) {
            if (!this.skills.containsKey(skill)) {
                return;
            }
            this.skills.remove(skill);
        } else {
            this.skills.put(skill, new SkillEntry(newLevel, newMasterlevel, expiration));
        }
        if (GameConstants.isRecoveryIncSkill(skill.getId())) {
            this.stats.relocHeal();
        } else if (GameConstants.isElementAmpSkill(skill.getId())) {
            this.stats.recalcLocalStats();
        }
    }

    public void changeSkillLevel_Skip(ISkill skill, byte newLevel, byte newMasterlevel) {
        if (skill == null) {
            return;
        }
        this.client.sendPacket(MaplePacketCreator.updateSkill(skill.getId(), (int) newLevel, (int) newMasterlevel, -1L));
        if (newLevel == 0 && newMasterlevel == 0) {
            if (this.skills.containsKey(skill)) {
                this.skills.remove(skill);
            }
        } else {
            this.skills.put(skill, new SkillEntry(newLevel, newMasterlevel, -1L));
        }
    }

    public void playerDead() {
        if (this.getMapId() != 109020001) {
            MapleStatEffect statss = this.getStatForBuff(MapleBuffStat.SOUL_STONE);
            if (statss != null) {
                this.dropMessage(5, "你已经透过灵魂之石复活了。");
                this.getStat().setHp(this.getStat().getMaxHp() / 100 * statss.getX());
                this.setStance(0);
                this.changeMap(this.getMap(), this.getMap().getPortal(0));
                return;
            }
        }
        if (this.getEventInstance() != null) {
            this.getEventInstance().playerKilled(this);
        }
        this.client.getSession().write(MaplePacketCreator.enableActions());
        this.dispelSkill(0);
        this.cancelEffectFromBuffStat(MapleBuffStat.MORPH);
        this.cancelEffectFromBuffStat(MapleBuffStat.MONSTER_RIDING);
        this.cancelEffectFromBuffStat(MapleBuffStat.SUMMON);
        this.cancelEffectFromBuffStat(MapleBuffStat.PUPPET);
        this.checkFollow();
        if (this.getMapId() != 109020001) {
            if (this.job != 0 && this.job != 1000 && this.job != 2000 && this.job != 2001 && this.job != 3000) {
                int charms = this.getItemQuantity(5130000, false);
                if (charms > 0) {
                    MapleInventoryManipulator.removeById(this.client, MapleInventoryType.CASH, 5130000, 1, true, false);
                    if (--charms > 255) {
                        charms = 255;
                    }
                    this.client.sendPacket(MTSCSPacket.useCharm((byte) charms, (byte) 0));
                } else {
                    int expforlevel = GameConstants.getExpNeededForLevel((int) this.level);
                    float diepercentage;
                    if (this.map.isTown() || FieldLimitType.RegularExpLoss.check(this.map.getFieldLimit())) {
                        diepercentage = 0.01f;
                    } else {
                        float v8;
                        if (this.job / 100 == 3) {
                            v8 = 0.08f;
                        } else {
                            v8 = 0.2f;
                        }
                        diepercentage = (float) ((double) (v8 / (float) this.stats.getLuk()) + 0.05);
                    }
                    int v9 = (int) ((long) this.exp - (long) ((double) expforlevel * (double) diepercentage));
                    if (v9 < 0) {
                        v9 = 0;
                    }
                    this.exp = v9;
                }
            }
            this.updateSingleStat(MapleStat.EXP, this.exp);
            this.client.getSession().write(MaplePacketCreator.enableActions());
            if (!this.stats.checkEquipDurabilitys(this, -100)) {
                this.dropMessage(5, "该装备耐久度已经使用完毕，必须修理才可以继续使用。");
            }
        }
        if (this.pyramidSubway != null) {
            this.stats.setHp(50);
            this.pyramidSubway.fail(this);
        }
        this.client.getSession().write(MaplePacketCreator.enableActions());
    }

    public void updatePartyMemberHP() {
        if (this.party != null) {
            int channel = this.client.getChannel();
            for (MaplePartyCharacter partychar : this.party.getMembers()) {
                if (partychar.getMapid() == this.getMapId() && partychar.getChannel() == channel) {
                    MapleCharacter other = this.client.getChannelServer().getPlayerStorage().getCharacterByName(partychar.getName());
                    if (other == null) {
                        continue;
                    }
                    other.getClient().sendPacket(MaplePacketCreator.updatePartyMemberHP(this.getId(), (int) this.stats.getHp(), (int) this.stats.getCurrentMaxHp()));
                }
            }
        }
    }

    public void receivePartyMemberHP() {
        if (this.party == null) {
            return;
        }
        int channel = this.client.getChannel();
        for (MaplePartyCharacter partychar : this.party.getMembers()) {
            if (partychar.getMapid() == this.getMapId() && partychar.getChannel() == channel) {
                MapleCharacter other = this.client.getChannelServer().getPlayerStorage().getCharacterByName(partychar.getName());
                if (other == null) {
                    continue;
                }
                this.client.sendPacket(MaplePacketCreator.updatePartyMemberHP(other.getId(), (int) other.getStat().getHp(), (int) other.getStat().getCurrentMaxHp()));
            }
        }
    }

    public void healHP(int delta) {
        this.healHP(delta, false);
    }

    public void healHP(int delta, boolean Show) {
        this.addHP(delta);
        if (Show) {
            this.client.sendPacket(MaplePacketCreator.showOwnHpHealed(delta));
            this.getMap().broadcastMessage(this, MaplePacketCreator.showHpHealed(this.getId(), delta), false);
        }
    }

    public void healMP(int delta) {
        this.addMP(delta);
    }

    public void addHP(int delta) {
        if (this.stats.setHp(this.stats.getHp() + delta)) {
            this.updateSingleStat(MapleStat.HP, (int) this.stats.getHp());
        }
    }

    public void addMP(int delta) {
        if (this.stats.setMp(this.stats.getMp() + delta)) {
            this.updateSingleStat(MapleStat.MP, (int) this.stats.getMp());
        }
    }

    public void addMPHP(int hpDiff, int mpDiff) {
        Map<MapleStat, Integer> statups = new EnumMap(MapleStat.class);
        if (this.stats.setHp(this.stats.getHp() + hpDiff)) {
            statups.put(MapleStat.HP, Integer.valueOf((int) this.stats.getHp()));
        }
        if (this.stats.setMp(this.stats.getMp() + mpDiff)) {
            statups.put(MapleStat.MP, Integer.valueOf((int) this.stats.getMp()));
        }
        if (statups.size() > 0) {
            this.client.sendPacket(MaplePacketCreator.updatePlayerStats(statups, this));
        }
    }

    public void 转生回归() {
        MapleCharacter player = this.client.getPlayer();
        boolean 转生开关 = Boolean.parseBoolean(ServerProperties.getProperty("cc.转生开关"));
        int 转生最大次数 = Integer.parseInt(ServerProperties.getProperty("cc.转生最大次数"));
        boolean 转生等级开关 = Boolean.parseBoolean(ServerProperties.getProperty("cc.转生等级开关"));
        short 转生等级变几级 = Short.parseShort(ServerProperties.getProperty("cc.转生等级变几级"));
        boolean 转生四维开关 = Boolean.parseBoolean(ServerProperties.getProperty("cc.转生四维开关"));
        short 转生后力量 = Short.parseShort(ServerProperties.getProperty("cc.转生后力量"));
        short 转生后敏捷 = Short.parseShort(ServerProperties.getProperty("cc.转生后敏捷"));
        short 转生后智力 = Short.parseShort(ServerProperties.getProperty("cc.转生后智力"));
        short 转生后运气 = Short.parseShort(ServerProperties.getProperty("cc.转生后运气"));
        boolean 转生血量开关 = Boolean.parseBoolean(ServerProperties.getProperty("cc.转生血量开关"));
        short 转生后血量 = Short.parseShort(ServerProperties.getProperty("cc.转生后血量"));
        boolean 转生蓝量开关 = Boolean.parseBoolean(ServerProperties.getProperty("cc.转生蓝量开关"));
        short 转生后蓝量 = Short.parseShort(ServerProperties.getProperty("cc.转生后蓝量"));
        boolean 转生技能删除开关 = Boolean.parseBoolean(ServerProperties.getProperty("cc.转生技能删除开关"));
        boolean 转生职业变新手开关 = Boolean.parseBoolean(ServerProperties.getProperty("cc.转生职业变新手开关"));
        boolean 转生后是否加属性 = Boolean.parseBoolean(ServerProperties.getProperty("cc.转生后是否加属性开关"));
        Short 转生后一转给属性点 = Short.valueOf(Short.parseShort(ServerProperties.getProperty("cc.转生后一转给属性点")));
        Short 转生后二转给属性点 = Short.valueOf(Short.parseShort(ServerProperties.getProperty("cc.转生后二转给属性点")));
        Short 转生后三转给属性点 = Short.valueOf(Short.parseShort(ServerProperties.getProperty("cc.转生后三转给属性点")));
        Short 转生后四转给属性点 = Short.valueOf(Short.parseShort(ServerProperties.getProperty("cc.转生后四转给属性点")));
        Short 转生后五转给属性点 = Short.valueOf(Short.parseShort(ServerProperties.getProperty("cc.转生后五转给属性点")));
        Short 转生后六转给属性点 = Short.valueOf(Short.parseShort(ServerProperties.getProperty("cc.转生后六转给属性点")));
        Short 转生后七转给属性点 = Short.valueOf(Short.parseShort(ServerProperties.getProperty("cc.转生后七转给属性点")));
        Short 转生后八转给属性点 = Short.valueOf(Short.parseShort(ServerProperties.getProperty("cc.转生后八转给属性点")));
        Short 转生后九转给属性点 = Short.valueOf(Short.parseShort(ServerProperties.getProperty("cc.转生后九转给属性点")));
        Short 转生后十转给属性点 = Short.valueOf(Short.parseShort(ServerProperties.getProperty("cc.转生后十转给属性点")));
        Short 转生后十一转给属性点 = Short.valueOf(Short.parseShort(ServerProperties.getProperty("cc.转生后十一转给属性点")));
        Short 转生后十二转给属性点 = Short.valueOf(Short.parseShort(ServerProperties.getProperty("cc.转生后十二转给属性点")));
        Short 转生后十三转给属性点 = Short.valueOf(Short.parseShort(ServerProperties.getProperty("cc.转生后十三转给属性点")));
        Short 转生后十四转给属性点 = Short.valueOf(Short.parseShort(ServerProperties.getProperty("cc.转生后十四转给属性点")));
        Short 转生后十五转给属性点 = Short.valueOf(Short.parseShort(ServerProperties.getProperty("cc.转生后十五转给属性点")));
        Short 转生后十六转给属性点 = Short.valueOf(Short.parseShort(ServerProperties.getProperty("cc.转生后十六转给属性点")));
        Short 转生后十七转给属性点 = Short.valueOf(Short.parseShort(ServerProperties.getProperty("cc.转生后十七转给属性点")));
        Short 转生后十八转给属性点 = Short.valueOf(Short.parseShort(ServerProperties.getProperty("cc.转生后十八转给属性点")));
        Short 转生后十九转给属性点 = Short.valueOf(Short.parseShort(ServerProperties.getProperty("cc.转生后十九转给属性点")));
        Short 转生后二十转给属性点 = Short.valueOf(Short.parseShort(ServerProperties.getProperty("cc.转生后二十转给属性点")));
        Short 转生后一转给技能点 = Short.valueOf(Short.parseShort(ServerProperties.getProperty("cc.转生后一转给技能点")));
        Short 转生后二转给技能点 = Short.valueOf(Short.parseShort(ServerProperties.getProperty("cc.转生后二转给技能点")));
        Short 转生后三转给技能点 = Short.valueOf(Short.parseShort(ServerProperties.getProperty("cc.转生后三转给技能点")));
        Short 转生后四转给技能点 = Short.valueOf(Short.parseShort(ServerProperties.getProperty("cc.转生后四转给技能点")));
        Short 转生后五转给技能点 = Short.valueOf(Short.parseShort(ServerProperties.getProperty("cc.转生后五转给技能点")));
        Short 转生后六转给技能点 = Short.valueOf(Short.parseShort(ServerProperties.getProperty("cc.转生后六转给技能点")));
        Short 转生后七转给技能点 = Short.valueOf(Short.parseShort(ServerProperties.getProperty("cc.转生后七转给技能点")));
        Short 转生后八转给技能点 = Short.valueOf(Short.parseShort(ServerProperties.getProperty("cc.转生后八转给技能点")));
        Short 转生后九转给技能点 = Short.valueOf(Short.parseShort(ServerProperties.getProperty("cc.转生后九转给技能点")));
        Short 转生后十转给技能点 = Short.valueOf(Short.parseShort(ServerProperties.getProperty("cc.转生后十转给技能点")));
        Short 转生后十一转给技能点 = Short.valueOf(Short.parseShort(ServerProperties.getProperty("cc.转生后十一转给技能点")));
        Short 转生后十二转给技能点 = Short.valueOf(Short.parseShort(ServerProperties.getProperty("cc.转生后十二转给技能点")));
        Short 转生后十三转给技能点 = Short.valueOf(Short.parseShort(ServerProperties.getProperty("cc.转生后十三转给技能点")));
        Short 转生后十四转给技能点 = Short.valueOf(Short.parseShort(ServerProperties.getProperty("cc.转生后十四转给技能点")));
        Short 转生后十五转给技能点 = Short.valueOf(Short.parseShort(ServerProperties.getProperty("cc.转生后十五转给技能点")));
        Short 转生后十六转给技能点 = Short.valueOf(Short.parseShort(ServerProperties.getProperty("cc.转生后十六转给技能点")));
        Short 转生后十七转给技能点 = Short.valueOf(Short.parseShort(ServerProperties.getProperty("cc.转生后十七转给技能点")));
        Short 转生后十八转给技能点 = Short.valueOf(Short.parseShort(ServerProperties.getProperty("cc.转生后十八转给技能点")));
        Short 转生后十九转给技能点 = Short.valueOf(Short.parseShort(ServerProperties.getProperty("cc.转生后十九转给技能点")));
        Short 转生后二十转给技能点 = Short.valueOf(Short.parseShort(ServerProperties.getProperty("cc.转生后二十转给技能点")));
        Short 转生后给技能点 = Short.valueOf((short) 0);
        int 一转等级要求 = Integer.parseInt(ServerProperties.getProperty("cc.一转等级要求"));
        int 二转等级要求 = Integer.parseInt(ServerProperties.getProperty("cc.二转等级要求"));
        int 三转等级要求 = Integer.parseInt(ServerProperties.getProperty("cc.三转等级要求"));
        int 四转等级要求 = Integer.parseInt(ServerProperties.getProperty("cc.四转等级要求"));
        int 五转等级要求 = Integer.parseInt(ServerProperties.getProperty("cc.五转等级要求"));
        int 六转等级要求 = Integer.parseInt(ServerProperties.getProperty("cc.六转等级要求"));
        int 七转等级要求 = Integer.parseInt(ServerProperties.getProperty("cc.七转等级要求"));
        int 八转等级要求 = Integer.parseInt(ServerProperties.getProperty("cc.八转等级要求"));
        int 九转等级要求 = Integer.parseInt(ServerProperties.getProperty("cc.九转等级要求"));
        int 十转等级要求 = Integer.parseInt(ServerProperties.getProperty("cc.十转等级要求"));
        int 十一转等级要求 = Integer.parseInt(ServerProperties.getProperty("cc.十一转等级要求"));
        int 十二转等级要求 = Integer.parseInt(ServerProperties.getProperty("cc.十二转等级要求"));
        int 十三转等级要求 = Integer.parseInt(ServerProperties.getProperty("cc.十三转等级要求"));
        int 十四转等级要求 = Integer.parseInt(ServerProperties.getProperty("cc.十四转等级要求"));
        int 十五转等级要求 = Integer.parseInt(ServerProperties.getProperty("cc.十五转等级要求"));
        int 十六转等级要求 = Integer.parseInt(ServerProperties.getProperty("cc.十六转等级要求"));
        int 十七转等级要求 = Integer.parseInt(ServerProperties.getProperty("cc.十七转等级要求"));
        int 十八转等级要求 = Integer.parseInt(ServerProperties.getProperty("cc.十八转等级要求"));
        int 十九转等级要求 = Integer.parseInt(ServerProperties.getProperty("cc.十九转等级要求"));
        int 二十转等级要求 = Integer.parseInt(ServerProperties.getProperty("cc.二十转等级要求"));
        if (转生开关) {
            int 转生等级要求 = 0;
            Short 转生后给属性点 = null;
            switch (player.getOneTimeLog("转生次数")) {
                case 0: {
                    转生等级要求 = 一转等级要求;
                    转生后给属性点 = 转生后一转给属性点;
                    转生后给技能点 = 转生后一转给技能点;
                    break;
                }
                case 1: {
                    转生等级要求 = 二转等级要求;
                    转生后给属性点 = 转生后二转给属性点;
                    转生后给技能点 = 转生后二转给技能点;
                    break;
                }
                case 2: {
                    转生等级要求 = 三转等级要求;
                    转生后给属性点 = 转生后三转给属性点;
                    转生后给技能点 = 转生后三转给技能点;
                    break;
                }
                case 3: {
                    转生等级要求 = 四转等级要求;
                    转生后给属性点 = 转生后四转给属性点;
                    转生后给技能点 = 转生后四转给技能点;
                    break;
                }
                case 4: {
                    转生等级要求 = 五转等级要求;
                    转生后给属性点 = 转生后五转给属性点;
                    转生后给技能点 = 转生后五转给技能点;
                    break;
                }
                case 5: {
                    转生等级要求 = 六转等级要求;
                    转生后给属性点 = 转生后六转给属性点;
                    转生后给技能点 = 转生后六转给技能点;
                    break;
                }
                case 6: {
                    转生等级要求 = 七转等级要求;
                    转生后给属性点 = 转生后七转给属性点;
                    转生后给技能点 = 转生后七转给技能点;
                    break;
                }
                case 7: {
                    转生等级要求 = 八转等级要求;
                    转生后给属性点 = 转生后八转给属性点;
                    转生后给技能点 = 转生后八转给技能点;
                    break;
                }
                case 8: {
                    转生等级要求 = 九转等级要求;
                    转生后给属性点 = 转生后九转给属性点;
                    转生后给技能点 = 转生后九转给技能点;
                    break;
                }
                case 9: {
                    转生等级要求 = 十转等级要求;
                    转生后给属性点 = 转生后十转给属性点;
                    转生后给技能点 = 转生后十转给技能点;
                    break;
                }
                case 10: {
                    转生等级要求 = 十一转等级要求;
                    转生后给属性点 = 转生后十一转给属性点;
                    转生后给技能点 = 转生后十一转给技能点;
                    break;
                }
                case 11: {
                    转生等级要求 = 十二转等级要求;
                    转生后给属性点 = 转生后十二转给属性点;
                    转生后给技能点 = 转生后十二转给技能点;
                    break;
                }
                case 12: {
                    转生等级要求 = 十三转等级要求;
                    转生后给属性点 = 转生后十三转给属性点;
                    转生后给技能点 = 转生后十三转给技能点;
                    break;
                }
                case 13: {
                    转生等级要求 = 十四转等级要求;
                    转生后给属性点 = 转生后十四转给属性点;
                    转生后给技能点 = 转生后十四转给技能点;
                    break;
                }
                case 14: {
                    转生等级要求 = 十五转等级要求;
                    转生后给属性点 = 转生后十五转给属性点;
                    转生后给技能点 = 转生后十五转给技能点;
                    break;
                }
                case 15: {
                    转生等级要求 = 十六转等级要求;
                    转生后给属性点 = 转生后十六转给属性点;
                    转生后给技能点 = 转生后十六转给技能点;
                    break;
                }
                case 16: {
                    转生等级要求 = 十七转等级要求;
                    转生后给属性点 = 转生后十七转给属性点;
                    转生后给技能点 = 转生后十七转给技能点;
                    break;
                }
                case 17: {
                    转生等级要求 = 十八转等级要求;
                    转生后给属性点 = 转生后十八转给属性点;
                    转生后给技能点 = 转生后十八转给技能点;
                    break;
                }
                case 18: {
                    转生等级要求 = 十九转等级要求;
                    转生后给属性点 = 转生后十九转给属性点;
                    转生后给技能点 = 转生后十九转给技能点;
                    break;
                }
                case 20: {
                    转生等级要求 = 二十转等级要求;
                    转生后给属性点 = 转生后二十转给属性点;
                    转生后给技能点 = 转生后二十转给技能点;
                    break;
                }
                default: {
                    player.dropMessage(6, "你已经二十转了,恭喜");
                    return;
                }
            }
            if (this.getLevel() < 转生等级要求) {
                player.dropMessage(6, "无法转生，等级不够");
                return;
            }
            player.getStat().setHp(1);
            player.updateSingleStat(MapleStat.HP, 1);
            player.getStat().setMp(1);
            player.updateSingleStat(MapleStat.MP, 1);
            if (转生血量开关) {
                player.getStat().setMaxHp(转生后血量);
                player.updateSingleStat(MapleStat.MAXHP, (int) 转生后血量);
            }
            if (转生蓝量开关) {
                player.getStat().setMaxMp(转生后蓝量);
                player.updateSingleStat(MapleStat.MAXMP, (int) 转生后蓝量);
            }
            if (转生四维开关) {
                player.getStat().setStr(转生后力量);
                player.getStat().setDex(转生后敏捷);
                player.getStat().setInt(转生后智力);
                player.getStat().setLuk(转生后运气);
                player.updateSingleStat(MapleStat.STR, (int) 转生后力量);
                player.updateSingleStat(MapleStat.DEX, (int) 转生后敏捷);
                player.updateSingleStat(MapleStat.INT, (int) 转生后智力);
                player.updateSingleStat(MapleStat.LUK, (int) 转生后运气);
            }
            if (转生等级开关) {
                player.setLevel(转生等级变几级);
                player.updateSingleStat(MapleStat.LEVEL, (int) 转生等级变几级);
            }
            if (转生职业变新手开关) {
                player.changeJob(0);
            }
            player.setOneTimeLog("转生次数");
            if (转生技能删除开关) {
                this.clearSkills();
            }
            this.setExp(0);
            this.updateSingleStat(MapleStat.EXP, 0);
            this.setRemainingAp((short) 0);
            this.updateSingleStat(MapleStat.AVAILABLEAP, 0);
            this.setRemainingSp(0);
            this.updateSingleStat(MapleStat.AVAILABLESP, 0);
            if (转生后是否加属性) {
                this.setRemainingAp(转生后给属性点.shortValue());
                this.updateSingleStat(MapleStat.AVAILABLEAP, (int) 转生后给属性点.shortValue());
            }
            if (!转生职业变新手开关) {
                this.setRemainingSp((int) 转生后给技能点.shortValue());
                this.updateSingleStat(MapleStat.AVAILABLESP, (int) 转生后给技能点.shortValue());
            }
        } else {
            player.dropMessage(6, "转生没有开启");
        }
        this.client.getSession().write(MaplePacketCreator.enableActions());
    }

    public void addMAXMPHP(int hpDiff, int mpDiff) {
        Map<MapleStat, Integer> statups = new EnumMap(MapleStat.class);
        if (this.stats.getMaxHp() + hpDiff < 30000) {
            statups.put(MapleStat.MAXHP, Integer.valueOf(this.stats.getMaxHp() + hpDiff));
            statups.put(MapleStat.HP, Integer.valueOf(this.stats.getHp() + hpDiff));
            this.stats.setHp(this.stats.getHp() + hpDiff);
            this.stats.setMaxHp((short) (this.stats.getMaxHp() + hpDiff));
        }
        if (this.stats.getMaxMp() + mpDiff < 30000) {
            statups.put(MapleStat.MAXMP, Integer.valueOf(this.stats.getMaxMp() + mpDiff));
            statups.put(MapleStat.MP, Integer.valueOf(this.stats.getMp() + mpDiff));
            this.stats.setMp(this.stats.getMp() + mpDiff);
            this.stats.setMaxMp((short) (this.stats.getMaxMp() + mpDiff));
        }
        if (statups.size() > 0) {
            this.client.getSession().write(MaplePacketCreator.updatePlayerStats(statups, this));
        }
    }

    public void updateSingleStat(MapleStat stat, int newval) {
        this.updateSingleStat(stat, newval, false);
    }

    public void updateSingleStat(MapleStat stat, int newval, boolean itemReaction) {
        if (stat == MapleStat.AVAILABLESP) {
            this.client.sendPacket(MaplePacketCreator.updateSp(this, itemReaction));
            return;
        }
        Map<MapleStat, Integer> statup = new EnumMap(MapleStat.class);
        statup.put(stat, Integer.valueOf(newval));
        this.client.sendPacket(MaplePacketCreator.updatePlayerStats(statup, itemReaction, this));
    }

    public void gainExp(int total, boolean show, boolean inChat, boolean white) {
        try {
            int prevexp = this.getExp();
            int needed = GameConstants.getExpNeededForLevel((int) this.level);
            if (total > 0) {
                this.stats.checkEquipLevels(this, total);
            }
            if (this.level >= this.maxLevel) {
                this.setExp(0);
            } else {
                boolean leveled = false;
                boolean levelUpTimesLimit = ((Integer) Start.ConfigValuesMap.get("等级连升开关")).intValue() > 0;
                int 等级连升多少级之前都有效果 = ((Integer) Start.ConfigValuesMap.get("等级范围")).intValue();
                this.exp += total;
                long oexp = (long) this.exp;
                short 等级 = this.level;
                while (oexp >= (long) needed) {
                    this.levelUp();
                    leveled = true;
                    oexp -= (long) needed;
                    ++等级;
                    needed = GameConstants.getExpNeededForLevel((int) 等级);
                    if (((Integer) Start.ConfigValuesMap.get("世界等级开关")).intValue() > 0 && 等级 >= Start.世界等级) {
                        break;
                    }
                    if (!levelUpTimesLimit || 等级 >= 等级连升多少级之前都有效果 || oexp < (long) needed || 等级 >= this.maxLevel) {
                        break;
                    }
                }
                if (total > 0) {
                    this.familyRep(prevexp, needed, leveled);
                }
            }
            if (total != 0) {
                if (this.exp < 0) {
                    if (total > 0) {
                        this.setExp(needed);
                    } else if (total < 0) {
                        this.setExp(0);
                    }
                }
                this.updateSingleStat(MapleStat.EXP, this.getExp());
                if (show) {
                    this.client.sendPacket(MaplePacketCreator.GainEXP_Others(total, inChat, white));
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
            FilePrinter.printError("MapleCharacter.txt", (Throwable) e);
        }
    }

    public void familyRep(int prevexp, int needed, boolean leveled) {
        if (this.mfc != null) {
            int onepercent = needed / 100;
            int percentrep = prevexp / onepercent + this.getExp() / onepercent;
            if (leveled) {
                percentrep = 100 - percentrep + this.level / 2;
            }
            if (percentrep > 0) {
                int sensen = Family.setRep(this.mfc.getFamilyId(), this.mfc.getSeniorId(), percentrep, (int) this.level);
                if (sensen > 0) {
                    Family.setRep(this.mfc.getFamilyId(), sensen, percentrep / 2, (int) this.level);
                }
            }
        }
    }

    public boolean isShowInfo() {
        return this.isAdmin();
    }

    public boolean isShowErr() {
        return this.isShowInfo();
    }

    public void gainExpMonster(int gain, boolean show, boolean white, byte pty, int wedding_EXP, int Class_Bonus_EXP, int Equipment_Bonus_EXP, int Premium_Bonus_EXP) {
        if (this == null) {
            return;
        }
        this.expirationTask(true, false);
        if (this.getExpm() > 1.0) {
            gain = (int) ((double) gain * this.getExpm());
        }
        if (this.isVip()) {
            gain = (int) ((double) gain * (1.0 + (double) this.getVipExpRate() / 100.0));
        }
        if (this.getStat().equippedRing) {
            if (pty > 1) {
                if (pty > 5) {
                    gain = (int) ((double) gain * 1.3);
                } else {
                    gain = (int) ((double) gain * (1.0 + (0.1 + 0.05 * (double) (pty - 1))));
                }
            } else {
                gain = (int) ((double) gain * 1.1);
            }
        }
        Premium_Bonus_EXP = 0;
        if (((Integer) Start.ConfigValuesMap.get("雇佣经验加成开关")).intValue() > 0) {
            boolean 雇佣 = World.hasMerchant(this.getAccountID());
            if (雇佣) {
                Premium_Bonus_EXP = (int) ((double) gain / 100.0 * (double) ((Integer) Start.ConfigValuesMap.get("雇佣经验加成比例")).intValue());
            }
        }
        int total = gain + Class_Bonus_EXP + Equipment_Bonus_EXP + Premium_Bonus_EXP + wedding_EXP;
        int partyinc = 0;
        int prevexp = this.getExp();
        if (pty > 1) {
            partyinc = (int) ((float) ((double) gain / 20.0) * (float) (pty + 1));
            if (((Integer) Start.ConfigValuesMap.get("特殊组队经验加成")).intValue() > 0) {
                boolean 判定 = false;
                int 比例 = 0;
                for (MaplePartyCharacter z : this.getParty().getMembers()) {
                    MapleCharacter m = this.getMap().getCharacterById(z.getId());
                    if (m != null) {
                        for (int a = 0; a < Start.特殊组队经验加成表.size(); ++a) {
                            if (m.getJob() == Integer.parseInt((String) Start.特殊组队经验加成表.get(a))) {
                                判定 = true;
                            }
                        }
                    }
                }
                if (判定) {
                    比例 = ((Integer) Start.ConfigValuesMap.get("修正组队经验加成")).intValue();
                } else {
                    比例 = ((Integer) Start.ConfigValuesMap.get("原始组队经验加成")).intValue();
                }
                partyinc = (int) ((float) ((double) gain / 100.0 * (double) 比例) * (float) pty);
            }
            total += partyinc;
        }
        if (gain > 0 && total < gain) {
            total = Integer.MAX_VALUE;
        }
        if (total > 0) {
            this.stats.checkEquipLevels(this, total);
        }
        int maxLevel = ((Integer) Start.ConfigValuesMap.get("角色最大等级")).intValue();
        int needed = GameConstants.getExpNeededForLevel((int) this.level);
        if (GameConstants.isKOC((int) this.job) && this.level >= ServerConfig.kocmaxlevel) {
            if (this.exp + total > needed) {
                this.setExp(needed);
            } else {
                this.exp += total;
            }
        } else if (this.level >= maxLevel) {
            this.setExp(0);
        } else {
            boolean leveled = false;
            if (this.exp + total >= needed || this.exp >= needed) {
                boolean levelUpTimesLimit = ((Integer) Start.ConfigValuesMap.get("等级连升开关")).intValue() > 0;
                int 等级连升多少级之前都有效果 = ((Integer) Start.ConfigValuesMap.get("等级范围")).intValue();
                this.exp += total;
                long oexp = (long) this.exp;
                short 等级 = this.level;
                while (oexp >= (long) needed) {
                    this.levelUp();
                    leveled = true;
                    oexp -= (long) needed;
                    ++等级;
                    needed = GameConstants.getExpNeededForLevel((int) 等级);
                    if (((Integer) Start.ConfigValuesMap.get("世界等级开关")).intValue() > 0 && 等级 >= Start.世界等级) {
                        break;
                    }
                    if (!levelUpTimesLimit || 等级 >= 等级连升多少级之前都有效果 || oexp < (long) needed || 等级 >= maxLevel) {
                        break;
                    }
                }
                if (this.level >= maxLevel) {
                    this.setExp(0);
                } else {
                    needed = GameConstants.getExpNeededForLevel((int) this.level);
                    if (this.exp >= needed) {
                        this.setExp(needed);
                    }
                }
            } else {
                this.exp += total;
            }
            if (total > 0) {
                this.familyRep(prevexp, needed, leveled);
            }
        }
        if (gain != 0) {
            if (this.exp < 0) {
                if (gain > 0) {
                    this.setExp(GameConstants.getExpNeededForLevel((int) this.level));
                } else if (gain < 0) {
                    this.setExp(0);
                }
            }
            this.updateSingleStat(MapleStat.EXP, this.getExp());
            if (show) {
                this.client.sendPacket(MaplePacketCreator.GainEXP_Monster(gain, white, wedding_EXP, partyinc, Class_Bonus_EXP, Equipment_Bonus_EXP, Premium_Bonus_EXP));
            }
        }
    }

    public void reloadC() {
        this.client.getPlayer().getClient().sendPacket(MaplePacketCreator.getCharInfo(this.client.getPlayer()));
        this.client.getPlayer().getMap().removePlayer(this.client.getPlayer());
        this.client.getPlayer().getMap().addPlayer(this.client.getPlayer());
    }

    public MapleClient getPlayers() {
        return this.c;
    }

    public void forceReAddItem_NoUpdate(IItem item, MapleInventoryType type) {
        this.getInventory(type).removeSlot(item.getPosition());
        this.getInventory(type).addFromDB(item);
    }

    public void forceReAddItem(IItem item, MapleInventoryType type) {
        this.forceReAddItem_NoUpdate(item, type);
        if (type != MapleInventoryType.UNDEFINED) {
            this.client.sendPacket(MaplePacketCreator.modifyInventory(false, new ModifyInventory(1, item)));
        }
    }

    public void forceReAddItem_Flag(IItem item, MapleInventoryType type) {
        this.forceReAddItem_NoUpdate(item, type);
        if (type != MapleInventoryType.UNDEFINED) {
            this.client.sendPacket(MaplePacketCreator.modifyInventory(false, new ModifyInventory(0, item)));
        }
    }

    public void silentPartyUpdate() {
        if (this.party != null) {
            Party.updateParty(this.party.getId(), PartyOperation.SILENT_UPDATE, new MaplePartyCharacter(this));
        }
    }

    public boolean isGM() {
        return this.gmLevel > 0;
    }

    public boolean isAdmin() {
        return this.gmLevel >= 5;
    }

    public int getGMLevel() {
        return this.gmLevel;
    }

    public boolean isPlayer() {
        return this.gmLevel == 0;
    }

    public boolean hasGmLevel(int level) {
        return this.gmLevel >= level;
    }

    public void setGmLevelHM(byte level) {
        this.gmLevel = level;
    }

    public MapleInventory getInventory(MapleInventoryType type) {
        return this.inventory[type.ordinal()];
    }

    public MapleInventory[] getInventorys() {
        return this.inventory;
    }

    public void expirationTask() {
        this.expirationTask(false);
    }

    public void expirationTask(boolean pending) {
        this.expirationTask(false, pending);
    }

    public void expirationTask(boolean packet, boolean pending) {
        if (pending) {
            if (this.pendingExpiration != null) {
                for (Integer z : this.pendingExpiration) {
                    this.client.sendPacket(MTSCSPacket.itemExpired(z.intValue()));
                }
            }
            this.pendingExpiration = null;
            if (this.pendingSkills != null) {
                for (Integer z : this.pendingSkills) {
                    this.client.sendPacket(MaplePacketCreator.updateSkill(z.intValue(), 0, 0, -1L));
                    this.client.sendPacket(MaplePacketCreator.serverNotice(5, "[" + SkillFactory.getSkillName(z.intValue()) + "] 技能已经过期，系统自动从技能栏位移除。"));
                }
            }
            this.pendingSkills = null;
            return;
        }
        List<Integer> ret = (List<Integer>) new ArrayList();
        long currenttime = System.currentTimeMillis();
        List<Pair<MapleInventoryType, IItem>> toberemove = (List<Pair<MapleInventoryType, IItem>>) new ArrayList();
        List<IItem> tobeunlock = (List<IItem>) new ArrayList();
        for (MapleInventoryType inv : MapleInventoryType.values()) {
            for (IItem item : this.getInventory(inv)) {
                long expiration = item.getExpiration();
                if (expiration != -1L && !GameConstants.isPet(item.getItemId()) && currenttime > expiration) {
                    if (ItemFlag.LOCK.check((int) item.getFlag())) {
                        tobeunlock.add(item);
                    } else {
                        if (currenttime <= expiration) {
                            continue;
                        }
                        toberemove.add(new Pair(inv, item));
                    }
                } else {
                    if (item.getItemId() != 5000054 || item.getPet() == null || item.getPet().getSecondsLeft() > 0) {
                        continue;
                    }
                    toberemove.add(new Pair(inv, item));
                }
            }
        }
        for (Pair<MapleInventoryType, IItem> itemz : toberemove) {
            IItem item2 = (IItem) itemz.getRight();
            ret.add(Integer.valueOf(item2.getItemId()));
            if (packet) {
                this.getInventory((MapleInventoryType) itemz.getLeft()).removeItem(item2.getPosition(), item2.getQuantity(), false, this);
            } else {
                this.getInventory((MapleInventoryType) itemz.getLeft()).removeItem(item2.getPosition(), item2.getQuantity(), false);
            }
        }
        for (IItem itemz2 : tobeunlock) {
            itemz2.setExpiration(-1L);
            itemz2.setFlag((byte) (itemz2.getFlag() - ItemFlag.LOCK.getValue()));
        }
        this.pendingExpiration = ret;
        List<Integer> skilz = (List<Integer>) new ArrayList();
        List<ISkill> toberem = (List<ISkill>) new ArrayList();
        for (Entry<ISkill, SkillEntry> skil : this.skills.entrySet()) {
            if (((SkillEntry) skil.getValue()).expiration != -1L && currenttime > ((SkillEntry) skil.getValue()).expiration) {
                toberem.add(skil.getKey());
            }
        }
        for (ISkill skil2 : toberem) {
            skilz.add(Integer.valueOf(skil2.getId()));
            this.skills.remove(skil2);
        }
        this.pendingSkills = skilz;
    }

    public MapleShop getShop() {
        return this.shop;
    }

    public void setShop(MapleShop shop) {
        this.shop = shop;
    }

    public int getMeso() {
        return this.meso;
    }

    public int[] getSavedLocations() {
        return this.savedLocations;
    }

    public int getSavedLocation(SavedLocationType type) {
        return this.savedLocations[type.getValue()];
    }

    public void saveLocation(SavedLocationType type) {
        this.savedLocations[type.getValue()] = this.getMapId();
    }

    public void saveLocation(SavedLocationType type, int mapz) {
        this.savedLocations[type.getValue()] = mapz;
    }

    public void clearSavedLocation(SavedLocationType type) {
        this.savedLocations[type.getValue()] = -1;
    }

    public void gainMeso(int gain, boolean show) {
        this.gainMeso(gain, show, false, false);
    }

    public void gainMeso(int gain, boolean show, boolean enableActions) {
        this.gainMeso(gain, show, enableActions, false);
    }

    public void gainMeso(int gain, boolean show, boolean enableActions, boolean inChat) {
        if (this.meso + gain < 0) {
            this.client.sendPacket(MaplePacketCreator.enableActions());
            return;
        }
        this.meso += gain;
        this.updateSingleStat(MapleStat.MESO, this.meso, enableActions);
        if (show) {
            this.client.sendPacket(MaplePacketCreator.showMesoGain(gain, inChat));
        }
    }

    public void controlMonster(MapleMonster monster, boolean aggro) {
        if (this.clone) {
            return;
        }
        monster.setController(this);
        this.controlled.add(monster);
        this.client.sendPacket(MobPacket.controlMonster(monster, false, aggro));
        monster.sendStatus(this.client);
    }

    public void stopControllingMonster(MapleMonster monster) {
        if (this.clone) {
            return;
        }
        if (monster != null && this.controlled.contains(monster)) {
            this.controlled.remove(monster);
        }
    }

    public void checkMonsterAggro(MapleMonster monster) {
        if (this.clone || monster == null) {
            return;
        }
        if (monster.getController() == this) {
            monster.setControllerHasAggro(true);
        } else {
            monster.switchController(this, true);
        }
    }

    public Set<MapleMonster> getControlled() {
        return this.controlled;
    }

    public int getControlledSize() {
        return this.controlled.size();
    }

    public int getAccountID() {
        return this.accountid;
    }

    public void mobKilled(int id, int skillID) {
        try {
            for (MapleQuestStatus q : this.quests.values()) {
                if (q.getStatus() == 1) {
                    if (!q.hasMobKills()) {
                        continue;
                    }
                    if (!q.mobKilled(id, skillID)) {
                        continue;
                    }
                    this.client.sendPacket(MaplePacketCreator.updateQuestMobKills(q));
                    if (!q.getQuest().canComplete(this, null)) {
                        continue;
                    }
                    this.client.sendPacket(MaplePacketCreator.getShowQuestCompletion(q.getQuest().getId()));
                }
            }
        } catch (Exception ex) {
            ex.printStackTrace();
            FileoutputUtil.outError("logs/杀死怪物计次异常.txt", (Throwable) ex);
        }
    }

    public List<MapleQuestStatus> getStartedQuests() {
        List<MapleQuestStatus> ret = (List<MapleQuestStatus>) new LinkedList();
        for (MapleQuestStatus q : this.quests.values()) {
            if (q.getStatus() == 1 && !q.isCustom()) {
                ret.add(q);
            }
        }
        return ret;
    }

    public List<MapleQuestStatus> getCompletedQuests() {
        List<MapleQuestStatus> ret = (List<MapleQuestStatus>) new LinkedList();
        for (MapleQuestStatus q : this.quests.values()) {
            if (q.getStatus() == 2 && !q.isCustom()) {
                ret.add(q);
            }
        }
        return ret;
    }

    public Map<ISkill, SkillEntry> getSkills() {
        return Collections.unmodifiableMap(this.skills);
    }

    public byte getSkillLevel(ISkill skill) {
        SkillEntry ret = (SkillEntry) this.skills.get(skill);
        if (ret == null || ret.skillevel <= 0) {
            return 0;
        }
        return (byte) Math.min((int) skill.getMaxLevel(), ret.skillevel + (skill.isBeginnerSkill() ? 0 : this.stats.incAllskill));
    }

    public byte getMasterLevel(int skill) {
        return this.getMasterLevel(SkillFactory.getSkill(skill));
    }

    public byte getMasterLevel(ISkill skill) {
        SkillEntry ret = (SkillEntry) this.skills.get(skill);
        if (ret == null) {
            return 0;
        }
        return ret.masterlevel;
    }

    public void levelUp() {
        if (this.getLevel() >= this.maxLevel) {
            return;
        }
        if (this.getLevel() >= this.maxLevel1) {
            return;
        }
        if (((Integer) Start.ConfigValuesMap.get("世界等级开关")).intValue() > 0 && this.getLevel() >= Start.世界等级) {
            return;
        }
        MapleCharacter player = this.client.getPlayer();
        boolean 转生后升级是否加血量 = Boolean.parseBoolean(ServerProperties.getProperty("cc.转生后升级是否加血量"));
        boolean 转生后升级是否加蓝量 = Boolean.parseBoolean(ServerProperties.getProperty("cc.转生后升级是否加蓝量"));
        boolean 转生后升级是否加属性 = Boolean.parseBoolean(ServerProperties.getProperty("cc.转生后升级是否加属性"));
        int 转生后一转升级给属性点 = Integer.parseInt(ServerProperties.getProperty("cc.转生后一转升级给属性点"));
        int 转生后二转升级给属性点 = Integer.parseInt(ServerProperties.getProperty("cc.转生后二转升级给属性点"));
        int 转生后三转升级给属性点 = Integer.parseInt(ServerProperties.getProperty("cc.转生后三转升级给属性点"));
        int 转生后四转升级给属性点 = Integer.parseInt(ServerProperties.getProperty("cc.转生后四转升级给属性点"));
        int 转生后五转升级给属性点 = Integer.parseInt(ServerProperties.getProperty("cc.转生后五转升级给属性点"));
        int 转生后六转升级给属性点 = Integer.parseInt(ServerProperties.getProperty("cc.转生后六转升级给属性点"));
        int 转生后七转升级给属性点 = Integer.parseInt(ServerProperties.getProperty("cc.转生后七转升级给属性点"));
        int 转生后八转升级给属性点 = Integer.parseInt(ServerProperties.getProperty("cc.转生后八转升级给属性点"));
        int 转生后九转升级给属性点 = Integer.parseInt(ServerProperties.getProperty("cc.转生后九转升级给属性点"));
        int 转生后十转升级给属性点 = Integer.parseInt(ServerProperties.getProperty("cc.转生后十转升级给属性点"));
        int 转生后升级给属性点 = 5;
        boolean 转生后升级是否加技能点 = Boolean.parseBoolean(ServerProperties.getProperty("cc.转生后升级是否加技能点"));
        int 转生后一转升级给技能点 = Integer.parseInt(ServerProperties.getProperty("cc.转生后一转升级给技能点"));
        int 转生后二转升级给技能点 = Integer.parseInt(ServerProperties.getProperty("cc.转生后二转升级给技能点"));
        int 转生后三转升级给技能点 = Integer.parseInt(ServerProperties.getProperty("cc.转生后三转升级给技能点"));
        int 转生后四转升级给技能点 = Integer.parseInt(ServerProperties.getProperty("cc.转生后四转升级给技能点"));
        int 转生后五转升级给技能点 = Integer.parseInt(ServerProperties.getProperty("cc.转生后五转升级给技能点"));
        int 转生后六转升级给技能点 = Integer.parseInt(ServerProperties.getProperty("cc.转生后六转升级给技能点"));
        int 转生后七转升级给技能点 = Integer.parseInt(ServerProperties.getProperty("cc.转生后七转升级给技能点"));
        int 转生后八转升级给技能点 = Integer.parseInt(ServerProperties.getProperty("cc.转生后八转升级给技能点"));
        int 转生后九转升级给技能点 = Integer.parseInt(ServerProperties.getProperty("cc.转生后九转升级给技能点"));
        int 转生后十转升级给技能点 = Integer.parseInt(ServerProperties.getProperty("cc.转生后十转升级给技能点"));
        int 转生后升级给技能点 = 3;
        switch (player.getOneTimeLog("转生次数")) {
            case 0: {
                转生后升级给属性点 = 5;
                转生后升级给技能点 = 3;
                break;
            }
            case 1: {
                转生后升级给属性点 = 转生后一转升级给属性点;
                转生后升级给技能点 = 转生后一转升级给属性点;
                break;
            }
            case 2: {
                转生后升级给属性点 = 转生后二转升级给属性点;
                转生后升级给技能点 = 转生后二转升级给技能点;
                break;
            }
            case 3: {
                转生后升级给属性点 = 转生后三转升级给属性点;
                转生后升级给技能点 = 转生后三转升级给技能点;
                break;
            }
            case 4: {
                转生后升级给属性点 = 转生后四转升级给属性点;
                转生后升级给技能点 = 转生后四转升级给技能点;
                break;
            }
            case 5: {
                转生后升级给属性点 = 转生后五转升级给属性点;
                转生后升级给技能点 = 转生后五转升级给技能点;
                break;
            }
            case 6: {
                转生后升级给属性点 = 转生后六转升级给属性点;
                转生后升级给技能点 = 转生后六转升级给技能点;
                break;
            }
            case 7: {
                转生后升级给属性点 = 转生后七转升级给属性点;
                转生后升级给技能点 = 转生后七转升级给技能点;
                break;
            }
            case 8: {
                转生后升级给属性点 = 转生后八转升级给属性点;
                转生后升级给技能点 = 转生后八转升级给技能点;
                break;
            }
            case 9: {
                转生后升级给属性点 = 转生后九转升级给属性点;
                转生后升级给技能点 = 转生后九转升级给技能点;
                break;
            }
            case 10: {
                转生后升级给属性点 = 转生后十转升级给属性点;
                转生后升级给技能点 = 转生后十转升级给技能点;
                break;
            }
            default: {
                转生后升级给属性点 = 5;
                转生后升级给技能点 = 3;
                break;
            }
        }
        if (player.getOneTimeLog("转生次数") > 0) {
            if (转生后升级是否加属性) {
                this.remainingAp += (short) 转生后升级给属性点;
            }
        } else if (GameConstants.isKOC((int) this.job)) {
            if (this.level <= 70) {
                this.remainingAp += 6;
            } else {
                this.remainingAp += 5;
            }
        } else {
            this.remainingAp += 5;
        }
        int maxhp = this.stats.getMaxHp();
        int maxmp = this.stats.getMaxMp();
        if (this.job == 0 || this.job == 1000 || this.job == 2000) {
            if (player.getOneTimeLog("转生次数") > 0) {
                if (转生后升级是否加血量) {
                    maxhp += Randomizer.rand(12, 16);
                }
                if (转生后升级是否加蓝量) {
                    maxmp += Randomizer.rand(10, 12);
                }
            } else {
                maxhp += Randomizer.rand(12, 16);
                maxmp += Randomizer.rand(10, 12);
            }
        } else if (this.job >= 100 && this.job <= 132) {
            ISkill improvingMaxHP = SkillFactory.getSkill(1000001);
            int slevel = this.getSkillLevel(improvingMaxHP);
            if (player.getOneTimeLog("转生次数") > 0) {
                if (转生后升级是否加血量) {
                    if (slevel > 0) {
                        maxhp += improvingMaxHP.getEffect(slevel).getX();
                    }
                    maxhp += Randomizer.rand(24, 28);
                }
                if (转生后升级是否加蓝量) {
                    maxmp += Randomizer.rand(4, 6);
                }
            } else {
                if (slevel > 0) {
                    maxhp += improvingMaxHP.getEffect(slevel).getX();
                }
                maxhp += Randomizer.rand(24, 28);
                maxmp += Randomizer.rand(4, 6);
            }
        } else if (this.job >= 200 && this.job <= 232) {
            ISkill improvingMaxMP = SkillFactory.getSkill(2000001);
            int slevel = this.getSkillLevel(improvingMaxMP);
            if (player.getOneTimeLog("转生次数") > 0) {
                if (转生后升级是否加蓝量) {
                    if (slevel > 0) {
                        maxmp += improvingMaxMP.getEffect(slevel).getX() * 2;
                    }
                    maxmp += Randomizer.rand(22, 24);
                }
                if (转生后升级是否加血量) {
                    maxhp += Randomizer.rand(10, 14);
                }
            } else {
                if (slevel > 0) {
                    maxmp += improvingMaxMP.getEffect(slevel).getX() * 2;
                }
                maxmp += Randomizer.rand(22, 24);
                maxhp += Randomizer.rand(10, 14);
            }
        } else if ((this.job >= 300 && this.job <= 322) || (this.job >= 400 && this.job <= 422) || (this.job >= 1300 && this.job <= 1311) || (this.job >= 1400 && this.job <= 1411)) {
            if (player.getOneTimeLog("转生次数") > 0) {
                if (转生后升级是否加血量) {
                    maxhp += Randomizer.rand(20, 24);
                }
                if (转生后升级是否加蓝量) {
                    maxmp += Randomizer.rand(14, 16);
                }
            } else {
                maxhp += Randomizer.rand(20, 24);
                maxmp += Randomizer.rand(14, 16);
            }
        } else if (this.job >= 500 && this.job <= 522) {
            ISkill improvingMaxHP = SkillFactory.getSkill(5100000);
            int slevel = this.getSkillLevel(improvingMaxHP);
            if (player.getOneTimeLog("转生次数") > 0) {
                if (转生后升级是否加血量) {
                    if (slevel > 0) {
                        maxhp += improvingMaxHP.getEffect(slevel).getX();
                    }
                    maxhp += Randomizer.rand(22, 26);
                }
                if (转生后升级是否加蓝量) {
                    maxmp += Randomizer.rand(18, 22);
                }
            } else {
                if (slevel > 0) {
                    maxhp += improvingMaxHP.getEffect(slevel).getX();
                }
                maxhp += Randomizer.rand(22, 26);
                maxmp += Randomizer.rand(18, 22);
            }
        } else if (this.job >= 1100 && this.job <= 1111) {
            ISkill improvingMaxHP = SkillFactory.getSkill(11000000);
            int slevel = this.getSkillLevel(improvingMaxHP);
            if (player.getOneTimeLog("转生次数") > 0) {
                if (转生后升级是否加血量) {
                    if (slevel > 0) {
                        maxhp += improvingMaxHP.getEffect(slevel).getX();
                    }
                    maxhp += Randomizer.rand(24, 28);
                }
                if (转生后升级是否加蓝量) {
                    maxmp += Randomizer.rand(4, 6);
                }
            } else {
                if (slevel > 0) {
                    maxhp += improvingMaxHP.getEffect(slevel).getX();
                }
                maxhp += Randomizer.rand(24, 28);
                maxmp += Randomizer.rand(4, 6);
            }
        } else if (this.job >= 1200 && this.job <= 1212) {
            ISkill improvingMaxMP = SkillFactory.getSkill(12000000);
            int slevel = this.getSkillLevel(improvingMaxMP);
            if (player.getOneTimeLog("转生次数") > 0) {
                if (转生后升级是否加蓝量) {
                    if (slevel > 0) {
                        maxmp += improvingMaxMP.getEffect(slevel).getX() * 2;
                    }
                    maxmp += Randomizer.rand(22, 24);
                }
                if (转生后升级是否加血量) {
                    maxhp += Randomizer.rand(10, 14);
                }
            } else {
                if (slevel > 0) {
                    maxmp += improvingMaxMP.getEffect(slevel).getX() * 2;
                }
                maxmp += Randomizer.rand(22, 24);
                maxhp += Randomizer.rand(10, 14);
            }
        } else if (this.job >= 1500 && this.job <= 1512) {
            ISkill improvingMaxHP = SkillFactory.getSkill(15100000);
            int slevel = this.getSkillLevel(improvingMaxHP);
            if (player.getOneTimeLog("转生次数") > 0) {
                if (转生后升级是否加血量) {
                    if (slevel > 0) {
                        maxhp += improvingMaxHP.getEffect(slevel).getX();
                    }
                    maxhp += Randomizer.rand(22, 26);
                }
                if (转生后升级是否加蓝量) {
                    maxmp += Randomizer.rand(18, 22);
                }
            } else {
                if (slevel > 0) {
                    maxhp += improvingMaxHP.getEffect(slevel).getX();
                }
                maxhp += Randomizer.rand(22, 26);
                maxmp += Randomizer.rand(18, 22);
            }
        } else if (this.job >= 2100 && this.job <= 2112) {
            if (player.getOneTimeLog("转生次数") > 0) {
                if (转生后升级是否加血量) {
                    maxhp += Randomizer.rand(50, 52);
                }
                if (转生后升级是否加蓝量) {
                    maxmp += Randomizer.rand(4, 6);
                }
            } else {
                maxhp += Randomizer.rand(50, 52);
                maxmp += Randomizer.rand(4, 6);
            }
        } else if (player.getOneTimeLog("转生次数") > 0) {
            if (转生后升级是否加血量) {
                maxhp += Randomizer.rand(50, 100);
            }
            if (转生后升级是否加蓝量) {
                maxmp += Randomizer.rand(50, 100);
            }
        } else {
            maxhp += Randomizer.rand(50, 100);
            maxmp += Randomizer.rand(50, 100);
        }
        if (player.getOneTimeLog("转生次数") > 0) {
            if (转生后升级是否加蓝量) {
                maxmp += this.stats.getTotalInt() / 10;
            }
        } else {
            maxmp += this.stats.getTotalInt() / 10;
        }
        this.exp -= GameConstants.getExpNeededForLevel((int) this.level);
        if (this.exp < 0) {
            this.exp = 0;
        }
        ++this.level;
        maxhp = (short) Math.min(30000, Math.abs(maxhp));
        maxmp = (short) Math.min(30000, Math.abs(maxmp));
        Map<MapleStat, Integer> statup = new EnumMap(MapleStat.class);
        statup.put(MapleStat.MAXHP, Integer.valueOf(maxhp));
        statup.put(MapleStat.MAXMP, Integer.valueOf(maxmp));
        statup.put(MapleStat.HP, Integer.valueOf(maxhp));
        statup.put(MapleStat.MP, Integer.valueOf(maxmp));
        statup.put(MapleStat.EXP, Integer.valueOf(this.exp));
        statup.put(MapleStat.LEVEL, Integer.valueOf((int) this.level));
        if ((this.job != 0 && this.job != 1000 && this.job != 2000 && this.job != 2001 && this.job != 3000 && this.level > 9) || this.job == 200) {
            if (player.getOneTimeLog("转生次数") > 0) {
                if (转生后升级是否加技能点) {
                    int[] remainingSp = this.remainingSp;
                    int skillBook = GameConstants.getSkillBook((int) this.job);
                    remainingSp[skillBook] += 转生后升级给技能点;
                    this.client.sendPacket(MaplePacketCreator.updateSp(this, false));
                }
            } else {
                int[] remainingSp2 = this.remainingSp;
                int skillBook2 = GameConstants.getSkillBook((int) this.job);
                remainingSp2[skillBook2] += 3;
                this.client.sendPacket(MaplePacketCreator.updateSp(this, false));
            }
        } else if (this.level <= 10) {
            this.stats.setStr((short) (this.stats.getStr() + this.remainingAp));
            this.remainingAp = 0;
            statup.put(MapleStat.STR, Integer.valueOf((int) this.stats.getStr()));
        }
        statup.put(MapleStat.AVAILABLEAP, Integer.valueOf((int) this.remainingAp));
        this.stats.setMaxHp((short) maxhp);
        this.stats.setMaxMp((short) maxmp);
        this.stats.setHp((int) (short) maxhp);
        this.stats.setMp((int) (short) maxmp);
        this.client.sendPacket(MaplePacketCreator.updatePlayerStats(statup, this));
        this.map.broadcastMessage(this, MaplePacketCreator.showForeignEffect(this.getId(), 0), false);
        this.stats.recalcLocalStats();
        this.silentPartyUpdate();
        this.guildUpdate();
        this.familyUpdate();
        this.DoLevelMsg();
        if (this.level >= 20 && this.level <= 25 && !this.isGM()) {
            this.DoLevelMap();
        }
        if ((this.job == 1000 || (this.job >= 1100 && this.job <= 1111) || (this.job >= 1200 && this.job <= 1212) || (this.job >= 1300 && this.job <= 1312) || (this.job >= 1400 && this.job <= 1412) || (this.job >= 1500 && this.job <= 1512)) && this.level == 120) {
            Broadcast.broadcastMessage(MaplePacketCreator.serverNotice(6, "[恭贺] 玩家" + this.getName() + " 皇家骑士团到达120级。"));
        }
        if (this.level == 200) {
            Broadcast.broadcastMessage(MaplePacketCreator.serverNotice(6, "[恭贺] 玩家" + this.getName() + " 到达200级。"));
        }
        if (this.level == 100 && this.getStLog() >= 1) {
            int stjfid = this.getStLogid(this.id);
            if (this.getStjfLog(stjfid) >= 1) {
                this.updateStjfLog(stjfid, this.getStjf(stjfid) + 1);
            } else {
                this.setStjfLog(stjfid, 1);
            }
        }
        if (!this.isGM() && ((Integer) Start.ConfigValuesMap.get("玩家升级喇叭")).intValue() > 0) {
            StringBuilder sb = new StringBuilder();
            sb.append("[公告事项]:");
            sb.append(this.getName()).append("在地图:" + this.map.getMapName()).append(",终于达到了").append((int) this.level).append("级,大家一起祝贺下吧。");
            Broadcast.broadcastMessage(MaplePacketCreator.serverNotice(6, sb.toString()));
        }
        FileoutputUtil.logToFile("logs/Data/升级日志.txt", "\r\n " + FileoutputUtil.NowTime() + " IP: " + this.getClient().getSession().remoteAddress().toString().split(":")[0] + " 账号: " + this.getClient().getAccountName() + " 玩家: " + this.getName() + " 升级到" + (int) this.level);
    }

    public void DoLevelMsg() {
        if (this.level == 200 && !this.isGM()) {
            StringBuilder sb = new StringBuilder("[恭喜] ");
            IItem medal = this.getInventory(MapleInventoryType.EQUIPPED).getItem((short) (-21));
            if (medal != null) {
                sb.append("<");
                sb.append(MapleItemInformationProvider.getInstance().getName(medal.getItemId()));
                sb.append("> ");
            }
            sb.append(this.getName());
            sb.append(" 达到了等级200级！请大家一起恭喜他！");
            Broadcast.broadcastMessage(MaplePacketCreator.serverNotice(6, sb.toString()));
        }
        if (GameConstants.isAran((int) this.job)) {
            switch (this.level) {
                case 30: {
                    this.client.sendPacket(MaplePacketCreator.startMapEffect("恭喜达到30等请回瑞恩岛二转吧。", 5120000, true));
                    break;
                }
                case 70: {
                    this.client.sendPacket(MaplePacketCreator.startMapEffect("恭喜达到70等请到冰原雪域长老公管三转吧。", 5120000, true));
                    break;
                }
                case 120: {
                    this.client.sendPacket(MaplePacketCreator.startMapEffect("恭喜达到120等请回神木村祭司森林四转吧。", 5120000, true));
                    break;
                }
            }
        }
        if (GameConstants.isKOC((int) this.job) && this.level == 70) {
            this.client.sendPacket(MaplePacketCreator.startMapEffect("恭喜达到70等请回耶雷弗三转吧。", 5120000, true));
        }
    }

    public void DoLevelMap() {
        boolean warp = false;
        int Return_Map = 0;
        switch (this.getMapId()) {
            case 910060000: {
                warp = true;
                Return_Map = 100010000;
                break;
            }
            case 910120000: {
                warp = true;
                Return_Map = 100040000;
                break;
            }
            case 910220000: {
                warp = true;
                Return_Map = 101040000;
                break;
            }
            case 910310000: {
                warp = true;
                Return_Map = 103010000;
                break;
            }
            case 912030000: {
                warp = true;
                Return_Map = 120010000;
                break;
            }
        }
        if (warp) {
            MapleMap warpMap = this.client.getChannelServer().getMapFactory().getMap(Return_Map);
            if (warpMap != null) {
                this.changeMap(warpMap, warpMap.getPortal(0));
                this.dropMessage("由于你的等级超过20，已经不符合新手需求，将把您传出训练场。");
            }
        }
    }

    public void changeKeybinding(int key, byte type, int action) {
        if (type != 0) {
            this.keylayout.Layout().put(Integer.valueOf(key), new Pair(Byte.valueOf(type), Integer.valueOf(action)));
        } else {
            this.keylayout.Layout().remove(Integer.valueOf(key));
        }
    }

    public void sendMacros() {
        int i = 0;
        if (i < 5) {
            this.client.sendPacket(MaplePacketCreator.getMacros(this.skillMacros));
        }
    }

    public void updateMacros(int position, SkillMacro updateMacro) {
        this.skillMacros[position] = updateMacro;
    }

    public SkillMacro[] getMacros() {
        return this.skillMacros;
    }

    public void tempban(String reason, Calendar duration, int greason, boolean bandIp) {
        try (Connection con = BeePool.getConnection()) {
            FileoutputUtil.logToFile("logs/Hack/Ban/MySql_input.txt", "\r\n[tempBan] " + FileoutputUtil.NowTime() + " IP: " + this.client.getSession().remoteAddress().toString().split(":")[0] + " MAC: " + this.getClient().getMacs() + " 理由: " + reason, false, false);
            PreparedStatement ps = con.prepareStatement("INSERT INTO ipbans (ip) VALUES (?)");
            ps.setString(1, this.client.getSession().remoteAddress().toString().split(":")[0]);
            ps.executeUpdate();
            ps.close();
            ps = con.prepareStatement("UPDATE accounts SET tempban = ?, banreason = ?, greason = ? WHERE id = ?");
            Timestamp TS = new Timestamp(duration.getTimeInMillis());
            ps.setTimestamp(1, TS);
            ps.setString(2, reason);
            ps.setInt(3, greason);
            ps.setInt(4, this.accountid);
            ps.execute();
            ps.close();
            
            this.client.disconnect(true, false);
        } catch (SQLException ex) {
            System.err.println("Error while tempbanning" + ex);
            FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) ex);
        }
    }

    public static boolean ban(String ip, String id, String reason, boolean accountId, int gmlevel, boolean hellban) {
        try (Connection con = BeePool.getConnection()) {
            if (!isVpn(ip) && id.matches("/[0-9]{1,3}\\..*")) {
                FileoutputUtil.logToFile("logs/Hack/Ban/MySql_input.txt", "\r\n[Ban-1] " + FileoutputUtil.NowTime() + " IP: " + ip + " 理由: " + reason, false, false);
                PreparedStatement ps = con.prepareStatement("INSERT INTO ipbans (ip) VALUES (?)");
                ps.setString(1, id);
                ps.executeUpdate();
                ps.close();
                return true;
            }
            PreparedStatement ps;
            if (accountId) {
                ps = con.prepareStatement("SELECT id FROM accounts WHERE name = ?");
            } else {
                ps = con.prepareStatement("SELECT accountid FROM characters WHERE name = ?");
            }
            boolean ret = false;
            ps.setString(1, id);
            try (ResultSet rs = ps.executeQuery()) {
                if (rs.next()) {
                    int z = rs.getInt(1);
                    try (PreparedStatement psb = con.prepareStatement("UPDATE accounts SET banned = 1, banreason = ? WHERE id = ? AND gm < ?")) {
                        psb.setString(1, reason);
                        psb.setInt(2, z);
                        psb.setInt(3, gmlevel);
                        psb.execute();
                        psb.close();
                    }
                    if (gmlevel > 100) {
                        try (PreparedStatement psa = con.prepareStatement("SELECT * FROM accounts WHERE id = ?")) {
                            psa.setInt(1, z);
                            try (ResultSet rsa = psa.executeQuery()) {
                                if (rsa.next()) {
                                    String sessionIP = rsa.getString("sessionIP");
                                    if (sessionIP != null && sessionIP.matches("/[0-9]{1,3}\\..*")) {
                                        FileoutputUtil.logToFile("logs/Hack/Ban/MySql_input.txt", "\r\n[Ban-2] " + FileoutputUtil.NowTime() + " IP: " + ip + " 理由: " + reason, false, false);
                                    }
                                    String macData = rsa.getString("macs");
                                    if (macData != null) {
                                        MapleClient.banMacs(macData);
                                    }
                                    if (hellban) {
                                        try (PreparedStatement pss = con.prepareStatement("UPDATE accounts SET banned = 1, banreason = ? WHERE email = ?" + ((sessionIP == null) ? "" : " OR SessionIP = ?"))) {
                                            pss.setString(1, reason);
                                            pss.setString(2, rsa.getString("email"));
                                            if (sessionIP != null) {
                                                pss.setString(3, sessionIP);
                                            }
                                            pss.execute();
                                        }
                                    }
                                }
                            }
                        }
                    }
                    ret = true;
                }
            }
            ps.close();
            
            return ret;
        } catch (SQLException ex) {
            System.err.println("Error while banning" + ex);
            FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) ex);
            return false;
        }
    }

    public boolean ban(String reason, boolean banIP, boolean autoban, boolean hellban) {
        if (this.lastmonthfameids == null) {
            throw new RuntimeException("Trying to ban a non-loaded character (testhack)");
        }
        String ip = this.client.getSessionIPAddress();
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = con.prepareStatement("UPDATE accounts SET banned = ?, banreason = ? WHERE id = ?");
            ps.setInt(1, autoban ? 2 : 1);
            ps.setString(2, reason);
            ps.setInt(3, this.accountid);
            ps.execute();
            ps.close();
            if (!isVpn(ip)) {
                FileoutputUtil.logToFile("logs/Hack/Ban/MySql_input.txt", "\r\n" + FileoutputUtil.NowTime() + " IP: " + ip + " MAC: " + this.getClient().getMacs() + " 理由: " + reason, false, false);
                ps = con.prepareStatement("INSERT INTO ipbans (ip) VALUES (?)");
                ps.setString(1, ip);
                ps.executeUpdate();
                ps.close();
                try {
                    for (ChannelServer cs : ChannelServer.getAllInstances()) {
                        for (MapleCharacter chr : cs.getPlayerStorage().getAllCharactersThreadSafe()) {
                            if (chr.getClient().getSessionIPAddress().equals(this.client.getSessionIPAddress()) && !chr.getClient().isGm()) {
                                chr.getClient().disconnect(true, false);
                                chr.getClient().getSession().close();
                            }
                        }
                    }
                } catch (Exception ex3) {
                }
            }
            this.client.banMacs();
            if (hellban) {
                try (PreparedStatement psa = con.prepareStatement("SELECT * FROM accounts WHERE id = ?")) {
                    psa.setInt(1, this.accountid);
                    try (ResultSet rsa = psa.executeQuery()) {
                        if (rsa.next()) {
                            try (PreparedStatement pss = con.prepareStatement("UPDATE accounts SET banned = ?, banreason = ? WHERE email = ? OR SessionIP = ?")) {
                                pss.setInt(1, autoban ? 2 : 1);
                                pss.setString(2, reason);
                                pss.setString(3, rsa.getString("email"));
                                pss.setString(4, ip);
                                pss.execute();
                                pss.close();
                            }
                        }
                        rsa.close();
                    }
                    psa.close();
                }
            }
            
        } catch (SQLException ex) {
            System.err.println("Error while banning" + ex);
            FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) ex);
            return false;
        }
        try {
            this.client.disconnect(true, false);
        } catch (Exception ex2) {
            FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) ex2);
        }
        return true;
    }

    public boolean OfflineBanByName(String name, String reason) {
        int id = 0;
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = null;
            ps = con.prepareStatement("select id from characters where name = ?");
            ps.setString(1, name);
            ResultSet rs = ps.executeQuery();
            if (rs.next()) {
                id = rs.getInt("id");
            }
            rs.close();
        } catch (Exception ex) {
            FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) ex);
        }
        return id != 0 && this.OfflineBanById(id, reason);
    }

    public boolean OfflineBanById(int id, String reason) {
        try (Connection con = BeePool.getConnection()) {
            Statement stmt = con.createStatement();
            int z = id;
            int acid = 0;
            String ip = "";
            String mac = "";
            ResultSet rs = stmt.executeQuery("select accountid from characters where id = " + id);
            while (rs.next()) {
                acid = rs.getInt("accountid");
            }
            if (acid == 0) {
                return false;
            }
            try (PreparedStatement psb = con.prepareStatement("UPDATE accounts SET banned = 1, banreason = ? WHERE id = ?")) {
                psb.setString(1, reason);
                psb.setInt(2, acid);
                psb.execute();
                psb.close();
            }
            rs = stmt.executeQuery("select SessionIP, macs from accounts where id = " + acid);
            while (rs.next()) {
                ip = rs.getString("SessionIP");
                mac = rs.getString("macs");
            }
            if (!isVpn(ip)) {
                FileoutputUtil.logToFile("logs/Hack/Ban/MySql_input.txt", "\r\n[offlineBan] " + FileoutputUtil.NowTime() + " IP: " + ip + " MAC: " + this.getClient().getMacs() + " 理由: " + reason, false, false);
                PreparedStatement ps = con.prepareStatement("INSERT INTO ipbans (ip) VALUES (?)");
                ps.setString(1, ip);
                ps.executeUpdate();
                ps.close();
                try {
                    for (ChannelServer cs : ChannelServer.getAllInstances()) {
                        for (MapleCharacter chr : cs.getPlayerStorage().getAllCharactersThreadSafe()) {
                            if (chr.getClient().getSessionIPAddress().equals(ip) && !chr.getClient().isGm()) {
                                chr.getClient().disconnect(true, false);
                                chr.getClient().getSession().close();
                            }
                        }
                    }
                } catch (Exception ex2) {
                }
            }
            MapleClient client = this.client;
            MapleClient.banMacs(mac);
            rs.close();
            stmt.close();
            
            return true;
        } catch (Exception ex) {
            System.err.println("封锁出现错误 " + ex);
            FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) ex);
            return false;
        }
    }

    @Override
    public int getObjectId() {
        return this.getId();
    }

    @Override
    public void setObjectId(int id) {
        throw new UnsupportedOperationException();
    }

    public MapleStorage getStorage() {
        return this.storage;
    }

    public void addVisibleMapObject(MapleMapObject mo) {
        if (this.clone) {
            return;
        }
        this.visibleMapObjectsLock.writeLock().lock();
        try {
            this.visibleMapObjects.add(mo);
        } finally {
            this.visibleMapObjectsLock.writeLock().unlock();
        }
    }

    public void removeVisibleMapObject(MapleMapObject mo) {
        if (this.clone) {
            return;
        }
        this.visibleMapObjectsLock.writeLock().lock();
        try {
            this.visibleMapObjects.remove(mo);
        } finally {
            this.visibleMapObjectsLock.writeLock().unlock();
        }
    }

    public boolean isMapObjectVisible(MapleMapObject mo) {
        this.visibleMapObjectsLock.readLock().lock();
        try {
            return !this.clone && this.visibleMapObjects.contains(mo);
        } finally {
            this.visibleMapObjectsLock.readLock().unlock();
        }
    }

    public Collection<MapleMapObject> getAndWriteLockVisibleMapObjects() {
        this.visibleMapObjectsLock.writeLock().lock();
        return this.visibleMapObjects;
    }

    public void unlockWriteVisibleMapObjects() {
        this.visibleMapObjectsLock.writeLock().unlock();
    }

    public boolean isAlive() {
        return this.stats.getHp() > 0;
    }

    @Override
    public void sendDestroyData(MapleClient client) {
        client.sendPacket(MaplePacketCreator.removePlayerFromMap(this.getObjectId()));
        for (WeakReference<MapleCharacter> chr : this.clones) {
            if (chr.get() != null) {
                ((MapleCharacter) chr.get()).sendDestroyData(client);
            }
        }
    }

    @Override
    public void sendSpawnData(MapleClient client) {
        if (client.getPlayer().allowedToTarget(this)) {
            client.sendPacket(MaplePacketCreator.spawnPlayerMapobject(this));
            if (this.getParty() != null && !this.isClone()) {
                this.updatePartyMemberHP();
                this.receivePartyMemberHP();
            }
            for (MaplePet pet : this.getSummonedPets()) {
                if (this.getId() != client.getPlayer().getId()) {
                    client.sendPacket(PetPacket.showPet(this, pet, false, false));
                }
            }
            for (WeakReference<MapleCharacter> chr : this.clones) {
                if (chr.get() != null) {
                    ((MapleCharacter) chr.get()).sendSpawnData(client);
                }
            }
            if (this.summons != null) {
                for (MapleSummon summon : this.summons.values()) {
                    client.sendPacket(MaplePacketCreator.spawnSummon(summon, false));
                }
            }
            if (this.followid > 0) {
                client.sendPacket(MaplePacketCreator.followEffect(this.followinitiator ? this.id : this.followid, this.followinitiator ? this.followid : this.id, null));
            }
        }
    }

    public void equipChanged() {
        if (this.map == null) {
            return;
        }
        this.map.broadcastMessage(this, MaplePacketCreator.updateCharLook(this), false);
        this.stats.recalcLocalStats();
        if (this.getMessenger() != null) {
            Messenger.updateMessenger(this.getMessenger().getId(), this.getName(), this.client.getChannel());
        }
        this.saveToDB(false, false);
    }

    public MaplePet getPet(int index) {
        byte count = 0;
        for (MaplePet pet : this.pets) {
            if (pet.getSummoned()) {
                if (count == index) {
                    return pet;
                }
                ++count;
            }
        }
        return null;
    }

    public void addPet(MaplePet pet) {
        if (this.pets.contains(pet)) {
            this.pets.remove(pet);
        }
        this.pets.add(pet);
    }

    public void removePet(MaplePet pet) {
        pet.setSummoned(0);
        this.pets.remove(pet);
    }

    public List<MaplePet> getSummonedPets() {
        List<MaplePet> ret = (List<MaplePet>) new ArrayList();
        for (int i = 0; i < 3; ++i) {
            ret.add(null);
        }
        for (int i = 0; i < 3; ++i) {
            for (MaplePet pet : this.pets) {
                if (pet != null && pet.getSummoned()) {
                    int index = pet.getSummonedValue() - 1;
                    if (index == i) {
                        ret.remove(index);
                        ret.add(index, pet);
                        break;
                    }
                    continue;
                }
            }
        }
        List<Integer> nullArr = (List<Integer>) new ArrayList();
        nullArr.add(null);
        ret.removeAll((Collection<?>) nullArr);
        return ret;
    }

    public MaplePet getSummonedPet(int index) {
        for (MaplePet pet : this.getSummonedPets()) {
            if (pet.getSummonedValue() - 1 == index) {
                return pet;
            }
        }
        return null;
    }

    public void shiftPetsRight() {
        List<MaplePet> petsz = this.getSummonedPets();
        if (petsz.size() >= 3 || petsz.size() < 1) {
            return;
        }
        boolean[] indexBool = {false, false, false};
        for (int i = 0; i < 3; ++i) {
            for (MaplePet p : petsz) {
                if (p.getSummonedValue() == i + 1) {
                    indexBool[i] = true;
                }
            }
        }
        if (petsz.size() > 1) {
            if (!indexBool[2]) {
                ((MaplePet) petsz.get(0)).setSummoned(2);
                ((MaplePet) petsz.get(1)).setSummoned(3);
            } else if (!indexBool[1]) {
                ((MaplePet) petsz.get(0)).setSummoned(2);
            }
        } else if (indexBool[0]) {
            ((MaplePet) petsz.get(0)).setSummoned(2);
        }
    }

    public int getPetSlotNext() {
        List<MaplePet> petsz = this.getSummonedPets();
        int index = 0;
        if (petsz.size() >= 3) {
            this.unequipPet(this.getSummonedPet(0), false);
        } else {
            boolean[] indexBool = {false, false, false};
            for (int i = 0; i < 3; ++i) {
                for (MaplePet p : petsz) {
                    if (p.getSummonedValue() == i + 1) {
                        indexBool[i] = true;
                        break;
                    }
                }
            }
            for (boolean b : indexBool) {
                if (!b) {
                    break;
                }
                ++index;
            }
            index = Math.min(index, 2);
            for (MaplePet p2 : petsz) {
                if (p2.getSummonedValue() == index + 1) {
                    this.unequipPet(p2, false);
                }
            }
        }
        return index;
    }

    public byte getPetIndex(MaplePet petz) {
        return (byte) Math.max(-1, petz.getSummonedValue() - 1);
    }

    public byte getPetIndex(int petId) {
        for (MaplePet pet : this.getSummonedPets()) {
            if (pet.getUniqueId() == petId) {
                return (byte) Math.max(-1, pet.getSummonedValue() - 1);
            }
        }
        return -1;
    }

    public List<MaplePet> getPets() {
        return this.pets;
    }

    public void unequipAllPets() {
        for (MaplePet pet : this.getSummonedPets()) {
            this.unequipPet(pet, false);
        }
    }

    public void unequipPet(MaplePet pet, boolean hunger) {
        if (pet.getSummoned()) {
            pet.saveToDb();
            List<MaplePet> summonedPets = this.getSummonedPets();
            if (summonedPets.contains(pet)) {
                summonedPets.remove(pet);
                int i = 1;
                for (MaplePet p : summonedPets) {
                    if (p == null) {
                        continue;
                    }
                    p.setSummoned(i);
                    ++i;
                }
            }
            if (this.map != null) {
                this.map.broadcastMessage(this, PetPacket.showPet(this, pet, true, hunger), true);
            }
            pet.setSummoned(0);
            this.client.sendPacket(PetPacket.petStatUpdate(this));
            this.client.sendPacket(MaplePacketCreator.enableActions());
        }
    }

    public long getLastFameTime() {
        return this.lastfametime;
    }

    public List<Integer> getFamedCharacters() {
        return this.lastmonthfameids;
    }

    public FameStatus canGiveFame(MapleCharacter from) {
        if (this.lastfametime >= System.currentTimeMillis() - 86400000L) {
            return FameStatus.NOT_TODAY;
        }
        if (from == null || this.lastmonthfameids == null || this.lastmonthfameids.contains(Integer.valueOf(from.getId()))) {
            return FameStatus.NOT_THIS_MONTH;
        }
        return FameStatus.OK;
    }

    public void hasGivenFame(MapleCharacter to) {
        this.lastfametime = System.currentTimeMillis();
        this.lastmonthfameids.add(to.getId());
        try (Connection con = BeePool.getConnection();
             PreparedStatement ps = con.prepareStatement("INSERT INTO famelog (characterid, characterid_to) VALUES (?, ?)")) {
            ps.setInt(1, this.getId());
            ps.setInt(2, to.getId());
            ps.execute();
        } catch (SQLException e) {
            System.err.println("ERROR writing famelog for char " + this.getName() + " to " + to.getName() + e);
            FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) e);
        }
    }

    public MapleKeyLayout getKeyLayout() {
        return this.keylayout;
    }

    public MapleParty getParty() {
        return this.party;
    }

    public int getPartyId() {
        return (this.party != null) ? this.party.getId() : -1;
    }

    public byte getWorld() {
        return this.world;
    }

    public void setWorld(byte world) {
        this.world = world;
    }

    public void setParty(MapleParty party) {
        this.party = party;
    }

    public MapleTrade getTrade() {
        return this.trade;
    }

    public void setTrade(MapleTrade trade) {
        this.trade = trade;
    }

    public EventInstanceManager getEventInstance() {
        return this.eventInstance;
    }

    public void setEventInstance(EventInstanceManager eventInstance) {
        this.eventInstance = eventInstance;
    }

    public void addDoor(MapleDoor door) {
        this.doors.add(door);
    }

    public void clearDoors() {
        this.doors.clear();
    }

    public List<MapleDoor> getDoors() {
        return new ArrayList(this.doors);
    }

    public void setSmega() {
        if (this.smega) {
            this.smega = false;
            this.dropMessage(5, "由于您关闭了显示广播，所以您看不见任何的广播，如果要打开请打@TSmega。");
        } else {
            this.smega = true;
            this.dropMessage(5, "目前已经打开显示广播，若要再次关闭请打@TSmega。");
        }
    }

    public boolean getSmega() {
        return this.smega;
    }

    public void setGashponmega() {
        if (this.gashponmega) {
            this.gashponmega = false;
            this.dropMessage(5, "由于您关闭了转蛋广播，所以您看不见任何的转蛋广播，如果要打开请打@Gashponmega。");
        } else {
            this.gashponmega = true;
            this.dropMessage(5, "目前已经打开显示转蛋广播，若要再次关闭请打@Gashponmega。");
        }
    }

    public boolean getGashponmega() {
        return this.gashponmega;
    }

    public Map<Integer, MapleSummon> getSummons() {
        return this.summons;
    }

    public int getChair() {
        return this.chair;
    }

    public int getItemEffect() {
        return this.itemEffect;
    }

    public void setChair(int chair) {
        this.chair = chair;
        this.stats.relocHeal();
    }

    public void setItemEffect(int itemEffect) {
        this.itemEffect = itemEffect;
    }

    @Override
    public MapleMapObjectType getType() {
        return MapleMapObjectType.PLAYER;
    }

    public int getFamilyId() {
        if (this.mfc == null) {
            return 0;
        }
        return this.mfc.getFamilyId();
    }

    public int getSeniorId() {
        if (this.mfc == null) {
            return 0;
        }
        return this.mfc.getSeniorId();
    }

    public int getJunior1() {
        if (this.mfc == null) {
            return 0;
        }
        return this.mfc.getJunior1();
    }

    public int getJunior2() {
        if (this.mfc == null) {
            return 0;
        }
        return this.mfc.getJunior2();
    }

    public int getCurrentRep() {
        return this.currentrep;
    }

    public int getTotalRep() {
        return this.totalrep;
    }

    public void setCurrentRep(int _rank) {
        this.currentrep = _rank;
        if (this.mfc != null) {
            this.mfc.setCurrentRep(_rank);
        }
    }

    public void setTotalRep(int _rank) {
        this.totalrep = _rank;
        if (this.mfc != null) {
            this.mfc.setTotalRep(_rank);
        }
    }

    public int getGuildId() {
        return this.guildid;
    }

    public byte getGuildRank() {
        return this.guildrank;
    }

    public int getCombat() {
        short[] TemporaryGroup = {-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -15, -16, -17, -18, -19, -26, -27, -28, -29, -101, -102, -103, -104, -105, -106, -107, -108, -109, -110, -111, -112, -113, -114, -115, -116, -118, -119, -121, -127, -128};
        int Num = 0;
        for (short i = 0; i < TemporaryGroup.length; ++i) {
            IEquip equip = (IEquip) this.getInventory(MapleInventoryType.EQUIPPED).getItem(TemporaryGroup[i]);
            if (equip != null) {
                if (((Integer) Start.ConfigValuesMap.get("战力修正")).intValue() > 0) {
                    Num += this.RuinStat1(equip);
                } else {
                    Num += this.RuinStat(equip);
                }
            }
        }
        return Num;
    }

    public int getComStr() {
        short[] TemporaryGroup = {-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -15, -16, -17, -18, -19, -26, -27, -28, -29, -101, -102, -103, -104, -105, -106, -107, -108, -109, -110, -111, -112, -113, -114, -115, -116, -118, -119, -121, -127, -128};
        int Num = 0;
        for (short i = 0; i < TemporaryGroup.length; ++i) {
            IEquip equip = (IEquip) this.getInventory(MapleInventoryType.EQUIPPED).getItem(TemporaryGroup[i]);
            if (equip != null) {
                if (((Integer) Start.ConfigValuesMap.get("战力修正")).intValue() > 0) {
                    Num += this.RuinStr(equip) * 10;
                } else {
                    Num += this.RuinStr(equip);
                }
            }
        }
        return Num;
    }

    public int getComDex() {
        short[] TemporaryGroup = {-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -15, -16, -17, -18, -19, -26, -27, -28, -29, -101, -102, -103, -104, -105, -106, -107, -108, -109, -110, -111, -112, -113, -114, -115, -116, -118, -119, -121, -127, -128};
        int Num = 0;
        for (short i = 0; i < TemporaryGroup.length; ++i) {
            IEquip equip = (IEquip) this.getInventory(MapleInventoryType.EQUIPPED).getItem(TemporaryGroup[i]);
            if (equip != null) {
                if (((Integer) Start.ConfigValuesMap.get("战力修正")).intValue() > 0) {
                    Num += this.RuinDex(equip) * 10;
                } else {
                    Num += this.RuinDex(equip);
                }
            }
        }
        return Num;
    }

    public int getComInt() {
        short[] TemporaryGroup = {-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -15, -16, -17, -18, -19, -26, -27, -28, -29, -101, -102, -103, -104, -105, -106, -107, -108, -109, -110, -111, -112, -113, -114, -115, -116, -118, -119, -121, -127, -128};
        int Num = 0;
        for (short i = 0; i < TemporaryGroup.length; ++i) {
            IEquip equip = (IEquip) this.getInventory(MapleInventoryType.EQUIPPED).getItem(TemporaryGroup[i]);
            if (equip != null) {
                if (((Integer) Start.ConfigValuesMap.get("战力修正")).intValue() > 0) {
                    Num += this.RuinInt(equip) * 10;
                } else {
                    Num += this.RuinInt(equip);
                }
            }
        }
        return Num;
    }

    public int getComLuk() {
        short[] TemporaryGroup = {-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -15, -16, -17, -18, -19, -26, -27, -28, -29, -101, -102, -103, -104, -105, -106, -107, -108, -109, -110, -111, -112, -113, -114, -115, -116, -118, -119, -121, -127, -128};
        int Num = 0;
        for (short i = 0; i < TemporaryGroup.length; ++i) {
            IEquip equip = (IEquip) this.getInventory(MapleInventoryType.EQUIPPED).getItem(TemporaryGroup[i]);
            if (equip != null) {
                if (((Integer) Start.ConfigValuesMap.get("战力修正")).intValue() > 0) {
                    Num += this.RuinLuk(equip) * 10;
                } else {
                    Num += this.RuinLuk(equip);
                }
            }
        }
        return Num;
    }

    public int getComWatk() {
        short[] TemporaryGroup = {-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -15, -16, -17, -18, -19, -26, -27, -28, -29, -101, -102, -103, -104, -105, -106, -107, -108, -109, -110, -111, -112, -113, -114, -115, -116, -118, -119, -121, -127, -128};
        int Num = 0;
        for (short i = 0; i < TemporaryGroup.length; ++i) {
            IEquip equip = (IEquip) this.getInventory(MapleInventoryType.EQUIPPED).getItem(TemporaryGroup[i]);
            if (equip != null) {
                if (((Integer) Start.ConfigValuesMap.get("战力修正")).intValue() > 0) {
                    Num += this.RuinWatk(equip) * 50;
                } else {
                    Num += this.RuinWatk(equip);
                }
            }
        }
        return Num;
    }

    public int getComMatk() {
        short[] TemporaryGroup = {-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -15, -16, -17, -18, -19, -26, -27, -28, -29, -101, -102, -103, -104, -105, -106, -107, -108, -109, -110, -111, -112, -113, -114, -115, -116, -118, -119, -121, -127, -128};
        int Num = 0;
        for (short i = 0; i < TemporaryGroup.length; ++i) {
            IEquip equip = (IEquip) this.getInventory(MapleInventoryType.EQUIPPED).getItem(TemporaryGroup[i]);
            if (equip != null) {
                if (((Integer) Start.ConfigValuesMap.get("战力修正")).intValue() > 0) {
                    Num += this.RuinMatk(equip) * 10;
                } else {
                    Num += this.RuinMatk(equip);
                }
            }
        }
        return Num;
    }

    public int getComMdef() {
        short[] TemporaryGroup = {-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -15, -16, -17, -18, -19, -26, -27, -28, -29, -101, -102, -103, -104, -105, -106, -107, -108, -109, -110, -111, -112, -113, -114, -115, -116, -118, -119, -121, -127, -128};
        int Num = 0;
        for (short i = 0; i < TemporaryGroup.length; ++i) {
            IEquip equip = (IEquip) this.getInventory(MapleInventoryType.EQUIPPED).getItem(TemporaryGroup[i]);
            if (equip != null) {
                if (((Integer) Start.ConfigValuesMap.get("战力修正")).intValue() > 0) {
                    Num += this.RuinMdef(equip) * 10;
                } else {
                    Num += this.RuinMdef(equip);
                }
            }
        }
        return Num;
    }

    public int getComWdef() {
        short[] TemporaryGroup = {-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -15, -16, -17, -18, -19, -26, -27, -28, -29, -101, -102, -103, -104, -105, -106, -107, -108, -109, -110, -111, -112, -113, -114, -115, -116, -118, -119, -121, -127, -128};
        int Num = 0;
        for (short i = 0; i < TemporaryGroup.length; ++i) {
            IEquip equip = (IEquip) this.getInventory(MapleInventoryType.EQUIPPED).getItem(TemporaryGroup[i]);
            if (equip != null) {
                if (((Integer) Start.ConfigValuesMap.get("战力修正")).intValue() > 0) {
                    Num += this.RuinWdef(equip) * 10;
                } else {
                    Num += this.RuinWdef(equip);
                }
            }
        }
        return Num;
    }

    public int getComHp() {
        short[] TemporaryGroup = {-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -15, -16, -17, -18, -19, -26, -27, -28, -29, -101, -102, -103, -104, -105, -106, -107, -108, -109, -110, -111, -112, -113, -114, -115, -116, -118, -119, -121, -127, -128};
        int Num = 0;
        for (short i = 0; i < TemporaryGroup.length; ++i) {
            IEquip equip = (IEquip) this.getInventory(MapleInventoryType.EQUIPPED).getItem(TemporaryGroup[i]);
            if (equip != null) {
                if (((Integer) Start.ConfigValuesMap.get("战力修正")).intValue() > 0) {
                    Num += this.RuinHp(equip) * 10;
                } else {
                    Num += this.RuinHp(equip);
                }
            }
        }
        return Num;
    }

    public int getComMp() {
        short[] TemporaryGroup = {-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -15, -16, -17, -18, -19, -26, -27, -28, -29, -101, -102, -103, -104, -105, -106, -107, -108, -109, -110, -111, -112, -113, -114, -115, -116, -118, -119, -121, -127, -128};
        int Num = 0;
        for (short i = 0; i < TemporaryGroup.length; ++i) {
            IEquip equip = (IEquip) this.getInventory(MapleInventoryType.EQUIPPED).getItem(TemporaryGroup[i]);
            if (equip != null) {
                if (((Integer) Start.ConfigValuesMap.get("战力修正")).intValue() > 0) {
                    Num += this.RuinMp(equip) * 10;
                } else {
                    Num += this.RuinMp(equip);
                }
            }
        }
        return Num;
    }

    public int RuinStat(IEquip equip) {
        return equip.getStr() + equip.getDex() + equip.getInt() + equip.getLuk() + equip.getWatk() + equip.getMatk() + equip.getMdef() + equip.getWdef() + equip.getUpgradeSlots() + equip.getLevel();
    }

    public int RuinStat1(IEquip equip) {
        return equip.getStr() * 10 + equip.getDex() * 10 + equip.getInt() * 10 + equip.getLuk() * 10 + equip.getWatk() * 50 + equip.getMatk() * 50 + equip.getMdef() + equip.getWdef();
    }

    public int RuinStr(IEquip equip) {
        return equip.getStr();
    }

    public int RuinDex(IEquip equip) {
        return equip.getDex();
    }

    public int RuinInt(IEquip equip) {
        return equip.getInt();
    }

    public int RuinLuk(IEquip equip) {
        return equip.getLuk();
    }

    public int RuinWatk(IEquip equip) {
        return equip.getWatk();
    }

    public int RuinMatk(IEquip equip) {
        return equip.getMatk();
    }

    public int RuinMdef(IEquip equip) {
        return equip.getMdef();
    }

    public int RuinWdef(IEquip equip) {
        return equip.getWdef();
    }

    public int RuinHp(IEquip equip) {
        return equip.getHp();
    }

    public int RuinMp(IEquip equip) {
        return equip.getMp();
    }

    public void setGuildId(int _id) {
        this.guildid = _id;
        if (this.guildid > 0) {
            if (this.mgc == null) {
                this.mgc = new MapleGuildCharacter(this);
            } else {
                this.mgc.setGuildId(this.guildid);
            }
        } else {
            this.mgc = null;
        }
    }

    public void setGuildRank(byte _rank) {
        this.guildrank = _rank;
        if (this.mgc != null) {
            this.mgc.setGuildRank(_rank);
        }
    }

    public MapleGuildCharacter getMGC() {
        return this.mgc;
    }

    public void setAllianceRank(byte rank) {
        this.allianceRank = rank;
        if (this.mgc != null) {
            this.mgc.setAllianceRank(rank);
        }
    }

    public byte getAllianceRank() {
        return this.allianceRank;
    }

    public MapleGuild getGuild() {
        if (this.getGuildId() <= 0) {
            return null;
        }
        return Guild.getGuild(this.getGuildId());
    }

    public void guildUpdate() {
        if (this.guildid <= 0) {
            return;
        }
        this.mgc.setLevel(this.level);
        this.mgc.setJobId((int) this.job);
        Guild.memberLevelJobUpdate(this.mgc);
    }

    public void saveGuildStatus() {
        MapleGuild.saveCharacterGuildInfo(this.guildid, this.guildrank, this.allianceRank, this.id);
    }

    public void familyUpdate() {
        if (this.mfc == null) {
            return;
        }
        Family.memberFamilyUpdate(this.mfc, this);
    }

    public void saveFamilyStatus() {
        try (Connection con = BeePool.getConnection();
             PreparedStatement ps = con.prepareStatement("UPDATE characters SET familyid = ?, seniorid = ?, junior1 = ?, junior2 = ? WHERE id = ?")) {
            if (this.mfc == null) {
                ps.setInt(1, 0);
                ps.setInt(2, 0);
                ps.setInt(3, 0);
                ps.setInt(4, 0);
            } else {
                ps.setInt(1, this.mfc.getFamilyId());
                ps.setInt(2, this.mfc.getSeniorId());
                ps.setInt(3, this.mfc.getJunior1());
                ps.setInt(4, this.mfc.getJunior2());
            }
            ps.setInt(5, this.id);
            ps.execute();
        } catch (SQLException se) {
            FilePrinter.printError("MapleCharacter.txt", (Throwable) se, "saveFamilyStatus");
            FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) se);
        }
    }

    public void modifyCSPoints(int type, int quantity) {
        this.modifyCSPoints(type, quantity, false);
    }

    public void dropMessage(String message) {
        this.dropMessage(6, message);
    }

    public void modifyCSPoints(int type, int quantity, boolean show) {
        switch (type) {
            case 1: {
                int Acash = this.getAcash();
                if (Acash + quantity < 0) {
                    if (show) {
                        this.dropMessage(-1, "目前点券点数已满，无法获得更多的点券点数");
                    }
                    return;
                }
                this.setAcash(Acash + quantity);
                break;
            }
            case 2: {
                if (this.maplepoints + quantity < 0) {
                    if (show) {
                        this.dropMessage(-1, "目前抵用已满，无法获得更多的抵用.");
                    }
                    return;
                }
                this.maplepoints += quantity;
                break;
            }
            case 3: {
                int Points = this.getPoints();
                if (Points + quantity < 0) {
                    if (show) {
                        this.dropMessage(-1, "目前红利点数已满，无法获得更多的红利点数");
                    }
                    return;
                }
                this.setPoints(Points + quantity);
                break;
            }
            case 5: {
                this.gainwzcz(this.id, quantity);
                this.dropMessage("您 " + ((quantity > 0) ? "获得 " : "失去") + quantity + "交易币");
                break;
            }
        }
        if (show && quantity != 0) {
            this.dropMessage(-1, "您已经 " + ((quantity > 0) ? "获得 " : "花费 ") + quantity + ((type == 1) ? " 点券点数." : ((type == 2) ? " 抵用." : "红利点数")));
            this.UpdateCash();
        }
    }

    public void UpdateCash() {
        this.getClient().sendPacket(MaplePacketCreator.showCharCash(this));
    }

    public int getCSPoints(int type) {
        switch (type) {
            case 1: {
                return this.getAcash();
            }
            case 2: {
                return this.maplepoints;
            }
            case 3: {
                return this.getPoints();
            }
            case 5: {
                return this.getwzcz(this.id);
            }
            default: {
                return 0;
            }
        }
    }

    public int getOfflineAcash(MapleCharacter victim) {
        return this.getAcash(victim);
    }

    public boolean hasEquipped(int itemid) {
        return this.inventory[MapleInventoryType.EQUIPPED.ordinal()].countById(itemid) >= 1;
    }

    public boolean haveItem(int itemid, int quantity, boolean checkEquipped, boolean greaterOrEquals) {
        MapleInventoryType type = GameConstants.getInventoryType(itemid);
        int possesed = this.inventory[type.ordinal()].countById(itemid);
        if (checkEquipped && type == MapleInventoryType.EQUIP) {
            possesed += this.inventory[MapleInventoryType.EQUIPPED.ordinal()].countById(itemid);
        }
        if (greaterOrEquals) {
            return possesed >= quantity;
        }
        return possesed == quantity;
    }

    public boolean haveItem(int itemid, int quantity) {
        return this.haveItem(itemid, quantity, true, true);
    }

    public boolean haveItem(int itemid) {
        return this.haveItem(itemid, 1, true, true);
    }

    public short haveItemPos(int itemid) {
        MapleInventoryType type = GameConstants.getInventoryType(itemid);
        IItem findById = this.inventory[type.ordinal()].findById(itemid);
        short possesed;
        if (findById != null) {
            possesed = findById.getPosition();
        } else {
            possesed = 100;
        }
        return possesed;
    }

    public void dropNPC(String message) {
        this.client.sendPacket(MaplePacketCreator.getNPCTalk(9010000, (byte) 0, message, "00 00", (byte) 0));
    }

    public void dropNPC(int npc, String message) {
        this.client.sendPacket(MaplePacketCreator.getNPCTalk(npc, (byte) 0, message, "00 00", (byte) 0));
    }

    public boolean getItemVac() {
        return this.itemVacs;
    }

    public boolean getMobVac() {
        return this.mobVacs;
    }

    public int getCombo() {
        return this.combo;
    }

    public void setCombo(int combo) {
        this.combo = combo;
        this.lastCombo = System.currentTimeMillis();
        this.getClient().getSession().writeAndFlush(MaplePacketCreator.updateCombo(combo));
        if (combo % 10 == 0 && combo >= 10 && combo <= 100) {
            if (this.getSkillLevel(21000000) < combo / 10) {
                return;
            }
            if (combo == 9 && this.getQuestStatus(10370) == 0) {
                this.giftMedal(1142134);
                MapleQuest.getInstance(10370).forceComplete(this, 0);
                this.dropMessage(5, "您刚才拿到了连续技高手勋章。");
            }
            if (combo == 4999 && this.getQuestStatus(10371) == 0) {
                this.giftMedal(1142135);
                MapleQuest.getInstance(10371).forceComplete(this, 0);
                this.dropMessage(5, "您刚才拿到了连续技达人勋章。");
            }
            if (combo == 14999 && this.getQuestStatus(10372) == 0) {
                this.giftMedal(1142136);
                MapleQuest.getInstance(10372).forceComplete(this, 0);
                this.dropMessage(5, "您刚才拿到了连续技之王勋章。");
            }
            SkillFactory.getSkill(21000000).getEffect(combo / 10).applyComboBuff(this, combo);
        } else if (combo < 10) {
            SkillFactory.getSkill(21000000).getEffect(combo / 10).applyComboBuff(this, 0);
        }
    }

    public long getLastCombo() {
        return this.lastCombo;
    }

    public void setLastCombo(long combo) {
        this.lastCombo = combo;
    }

    public int get副本地图() {
        return this.副本地图;
    }


    public void set副本地图(int 副本地图) {
        this.副本地图 = 副本地图;
    }

    public byte getBuddyCapacity() {
        return this.buddylist.getCapacity();
    }

    public void setBuddyCapacity(byte capacity) {
        this.buddylist.setCapacity(capacity);
        this.client.sendPacket(MaplePacketCreator.updateBuddyCapacity((int) capacity));
    }

    public MapleMessenger getMessenger() {
        return this.messenger;
    }

    public void setMessenger(MapleMessenger messenger) {
        this.messenger = messenger;
    }

    public void addCooldown(int skillId, long startTime, long length) {
        this.coolDowns.put(Integer.valueOf(skillId), new MapleCoolDownValueHolder(skillId, startTime, length));
    }

    public void removeCooldown(int skillId) {
        if (this.coolDowns.containsKey(Integer.valueOf(skillId))) {
            this.coolDowns.remove(Integer.valueOf(skillId));
        }
    }

    public boolean skillisCooling(int skillId) {
        return this.coolDowns.containsKey(Integer.valueOf(skillId));
    }

    public void giveCoolDowns(int skillid, long starttime, long length) {
        this.addCooldown(skillid, starttime, length);
    }

    public void giveCoolDowns(List<MapleCoolDownValueHolder> cooldowns) {
        if (cooldowns != null) {
            for (MapleCoolDownValueHolder cooldown : cooldowns) {
                this.coolDowns.put(Integer.valueOf(cooldown.skillId), cooldown);
                this.client.sendPacket(MaplePacketCreator.skillCooldown(cooldown.skillId, (int) ((cooldown.length - ((System.currentTimeMillis() - cooldown.startTime > cooldown.length) ? 0L : (System.currentTimeMillis() - cooldown.startTime))) / 1000L)));
            }
        } else {
            try (Connection con = BeePool.getConnection();
                 PreparedStatement ps = con.prepareStatement("SELECT SkillID,StartTime,length FROM skills_cooldowns WHERE charid = ?")) {
                ps.setInt(1, this.getId());
                ResultSet rs = ps.executeQuery();
                while (rs.next()) {
                    if (rs.getLong("length") + rs.getLong("StartTime") - System.currentTimeMillis() <= 0L) {
                        continue;
                    }
                    this.giveCoolDowns(rs.getInt("SkillID"), rs.getLong("StartTime"), rs.getLong("length"));
                }
                rs.close();
                this.deleteWhereCharacterId(con, "DELETE FROM skills_cooldowns WHERE charid = ?");
            } catch (SQLException e) {
                FilePrinter.printError("MapleCharcter.txt", (Throwable) e, "Error while retriving cooldown from SQL storage");
                FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) e);
            }
        }
    }

    public List<MapleCoolDownValueHolder> getCooldowns() {
        return new ArrayList(this.coolDowns.values());
    }

    public List<MapleDiseaseValueHolder> getAllDiseases() {
        return new ArrayList(this.diseases.values());
    }

    public boolean hasDisease(MapleDisease dis) {
        return this.diseases.keySet().contains(dis);
    }

    public void getDiseaseBuff(MapleDisease disease, MobSkill skill) {
        this.getDiseaseBuff(disease, skill.getX(), skill.getDuration(), skill.getSkillId(), skill.getSkillLevel());
    }

    public void getDiseaseBuff(MapleDisease disease, int x, long duration, int skillid, int level) {
        List<Pair<MapleDisease, Integer>> debuff = Collections.singletonList(new Pair(disease, Integer.valueOf(x)));
        if (!this.hasDisease(disease) && this.diseases.size() < 2) {
            if (disease != MapleDisease.SEDUCE && disease != MapleDisease.STUN && this.isActiveBuffedValue(2321005)) {
                return;
            }
            this.diseases.put(disease, new MapleDiseaseValueHolder(disease, System.currentTimeMillis(), duration));
            this.client.sendPacket(MaplePacketCreator.giveDebuff(debuff, skillid, level, (int) duration));
            this.map.broadcastMessage(this, MaplePacketCreator.giveForeignDebuff(this.id, debuff, skillid, level), false);
        }
    }

    public void giveSilentDebuff(List<MapleDiseaseValueHolder> ld) {
        if (ld != null) {
            for (MapleDiseaseValueHolder disease : ld) {
                this.diseases.put(disease.disease, disease);
            }
        }
    }

    public void dispelDebuff(MapleDisease debuff) {
        if (this.hasDisease(debuff)) {
            long mask = debuff.getValue();
            boolean first = debuff.isFirst();
            this.diseases.remove(debuff);
            this.client.sendPacket(MaplePacketCreator.cancelDebuff(mask, first));
            this.map.broadcastMessage(this, MaplePacketCreator.cancelForeignDebuff(this.id, mask, first), false);
        }
    }

    public void dispelDebuffs() {
        this.dispelDebuff(MapleDisease.CURSE);
        this.dispelDebuff(MapleDisease.DARKNESS);
        this.dispelDebuff(MapleDisease.POISON);
        this.dispelDebuff(MapleDisease.SEAL);
        this.dispelDebuff(MapleDisease.STUN);
        this.dispelDebuff(MapleDisease.WEAKEN);
    }

    public void cancelAllDebuffs() {
        this.diseases.clear();
    }

    public void setLevel(short level) {
        this.level = level;
    }

    public void sendNote(String to, String msg) {
        this.sendNote(to, msg, 0);
    }

    public void sendNote(String to, String msg, int fame) {
        MapleCharacterUtil.sendNote(to, this.getName(), msg, fame);
    }

    public void showNote() {
        try (Connection con = BeePool.getConnection();
             PreparedStatement ps = con.prepareStatement("SELECT * FROM notes WHERE `to`=?", 1005, 1008)) {
            ps.setString(1, this.getName());
            try (ResultSet rs = ps.executeQuery()) {
                rs.last();
                int count = rs.getRow();
                rs.first();
                this.client.sendPacket(MTSCSPacket.showNotes(rs, count));
            }
        } catch (SQLException e) {
            FilePrinter.printError("MapleCharacter.txt", (Throwable) e, "Unable to show note");
            FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) e);
        }
    }

    public void deleteNote(int id, int fame) {
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = con.prepareStatement("SELECT gift FROM notes WHERE `id`=?");
            ps.setInt(1, id);
            ResultSet rs = ps.executeQuery();
            if (rs.next() && rs.getInt("gift") == fame && fame > 0) {
                this.addFame(fame);
                this.updateSingleStat(MapleStat.FAME, (int) this.getFame());
                this.client.sendPacket(MaplePacketCreator.getShowFameGain(fame));
            }
            rs.close();
            ps.close();
            ps = con.prepareStatement("DELETE FROM notes WHERE `id`=?");
            ps.setInt(1, id);
            ps.execute();
            ps.close();
        } catch (SQLException e) {
            System.err.println("Unable to delete note" + e);
            FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) e);
        }
    }

    public int getmulungEnergy() {
        return this.mulung_energy;
    }

    public void mulungEnergyModify(boolean inc) {
        if (inc) {
            if (this.mulung_energy + 100 > 10000) {
                this.mulung_energy = 10000;
            } else {
                this.mulung_energy += 100;
            }
        } else {
            this.mulung_energy = 0;
        }
        if (this.isAdmin()) {
            this.mulung_energy = 10000;
        }
        this.client.sendPacket(MaplePacketCreator.MulungEnergy((int) this.mulung_energy));
    }

    public void writeMulungEnergy() {
        this.client.sendPacket(MaplePacketCreator.MulungEnergy((int) this.mulung_energy));
    }

    public void writeEnergy(String type, String inc) {
        this.client.sendPacket(MaplePacketCreator.sendPyramidEnergy(type, inc));
    }

    public void writeStatus(String type, String inc) {
        this.client.sendPacket(MaplePacketCreator.sendGhostStatus(type, inc));
    }

    public void writePoint(String type, String inc) {
        this.client.sendPacket(MaplePacketCreator.sendGhostPoint(type, inc));
    }

    public long getKeyDownSkill_Time() {
        return this.keydown_skill;
    }

    public void setKeyDownSkill_Time(long keydown_skill) {
        this.keydown_skill = keydown_skill;
    }

    public void checkBerserk() {
        if (this.BerserkSchedule != null) {
            this.BerserkSchedule.cancel(false);
            this.BerserkSchedule = null;
        }
        ISkill BerserkX = SkillFactory.getSkill(1320006);
        int skilllevel = this.getSkillLevel(BerserkX);
        if (skilllevel >= 1) {
            MapleStatEffect ampStat = BerserkX.getEffect(skilllevel);
            this.stats.Berserk = (this.stats.getHp() * 100 / this.stats.getMaxHp() <= ampStat.getX());
            try {
                this.BerserkSchedule = BuffTimer.getInstance().schedule((Runnable) new Runnable() {
                    @Override
                    public void run() {
                        MapleCharacter.this.checkBerserk();
                    }
                }, 10000L);
            } catch (RejectedExecutionException ex) {
            }
        }
    }

    private void prepareBeholderEffect() {
        if (this.beholderHealingSchedule != null) {
            this.beholderHealingSchedule.cancel(false);
        }
        if (this.beholderBuffSchedule != null) {
            this.beholderBuffSchedule.cancel(false);
        }
        ISkill bHealing = SkillFactory.getSkill(1320008);
        int bHealingLvl = this.getSkillLevel(bHealing);
        int berserkLvl = this.getSkillLevel(SkillFactory.getSkill(1320006));
        if (bHealingLvl > 0) {
            MapleStatEffect healEffect = bHealing.getEffect(bHealingLvl);
            int healInterval = healEffect.getX() * 1000;
            this.beholderHealingSchedule = BuffTimer.getInstance().register((Runnable) new Runnable() {
                @Override
                public void run() {
                    int remhppercentage = (int) Math.ceil((double) MapleCharacter.this.getStat().getHp() * 100.0 / (double) MapleCharacter.this.getStat().getMaxHp());
                    if (berserkLvl == 0 || remhppercentage >= berserkLvl + 10) {
                        MapleCharacter.this.addHP((int) healEffect.getHp());
                    }
                    MapleCharacter.this.client.sendPacket(MaplePacketCreator.showOwnBuffEffect(1321007, 2));
                    MapleCharacter.this.map.broadcastMessage(MaplePacketCreator.summonSkill(MapleCharacter.this.getId(), 1321007, 5));
                    MapleCharacter.this.map.broadcastMessage(MapleCharacter.this, MaplePacketCreator.showBuffeffect(MapleCharacter.this.getId(), 1321007, 2), false);
                }
            }, (long) healInterval, (long) healInterval);
        }
        ISkill bBuff = SkillFactory.getSkill(1320009);
        int bBuffLvl = this.getSkillLevel(bBuff);
        if (bBuffLvl > 0) {
            MapleStatEffect buffEffect = bBuff.getEffect(bBuffLvl);
            int buffInterval = buffEffect.getX() * 1000;
            this.beholderBuffSchedule = BuffTimer.getInstance().register((Runnable) new Runnable() {
                @Override
                public void run() {
                    buffEffect.applyTo(MapleCharacter.this);
                    MapleCharacter.this.client.sendPacket(MaplePacketCreator.showOwnBuffEffect(1321007, 2));
                    MapleCharacter.this.map.broadcastMessage(MaplePacketCreator.summonSkill(MapleCharacter.this.getId(), 1321007, Randomizer.nextInt(3) + 6));
                    MapleCharacter.this.map.broadcastMessage(MapleCharacter.this, MaplePacketCreator.showBuffeffect(MapleCharacter.this.getId(), 1321007, 2), false);
                }
            }, (long) buffInterval, (long) buffInterval);
        }
    }

    public void setChalkboard(String text) {
        this.chalktext = text;
        this.map.broadcastMessage(MTSCSPacket.useChalkboard(this.getId(), text));
    }

    public String getChalkboard() {
        return this.chalktext;
    }

    public MapleMount getMount() {
        return this.mount;
    }

    public int gmLevel() {
        return this.gmLevel;
    }

    public int[] getWishlist() {
        return this.wishlist;
    }

    public void clearWishlist() {
        for (int i = 0; i < 10; ++i) {
            this.wishlist[i] = 0;
        }
    }

    public int getWishlistSize() {
        int ret = 0;
        for (int i = 0; i < 10; ++i) {
            if (this.wishlist[i] > 0) {
                ++ret;
            }
        }
        return ret;
    }

    public void setWishlist(int[] wl) {
        this.wishlist = wl;
    }

    public int[] getRocks() {
        return this.rocks;
    }

    public int getRockSize() {
        int ret = 0;
        for (int i = 0; i < 10; ++i) {
            if (this.rocks[i] != 999999999) {
                ++ret;
            }
        }
        return ret;
    }

    public void deleteFromRocks(int map) {
        for (int i = 0; i < 10; ++i) {
            if (this.rocks[i] == map) {
                this.rocks[i] = 999999999;
                break;
            }
        }
    }

    public void addRockMap() {
        if (this.getRockSize() >= 10) {
            return;
        }
        this.rocks[this.getRockSize()] = this.getMapId();
    }

    public boolean isRockMap(int id) {
        for (int i = 0; i < 10; ++i) {
            if (this.rocks[i] == id) {
                return true;
            }
        }
        return false;
    }

    public int[] getRegRocks() {
        return this.regrocks;
    }

    public int getRegRockSize() {
        int ret = 0;
        for (int i = 0; i < 5; ++i) {
            if (this.regrocks[i] != 999999999) {
                ++ret;
            }
        }
        return ret;
    }

    public void deleteFromRegRocks(int map) {
        for (int i = 0; i < 5; ++i) {
            if (this.regrocks[i] == map) {
                this.regrocks[i] = 999999999;
                break;
            }
        }
    }

    public void addRegRockMap() {
        if (this.getRegRockSize() >= 5) {
            return;
        }
        this.regrocks[this.getRegRockSize()] = this.getMapId();
    }

    public boolean isRegRockMap(int id) {
        for (int i = 0; i < 5; ++i) {
            if (this.regrocks[i] == id) {
                return true;
            }
        }
        return false;
    }

    public List<LifeMovementFragment> getLastRes() {
        return this.lastres;
    }

    public void setLastRes(List<LifeMovementFragment> lastres) {
        this.lastres = lastres;
    }

    public void setMonsterBookCover(int bookCover) {
        this.bookCover = bookCover;
    }

    public int getMonsterBookCover() {
        return this.bookCover;
    }

    public String getAccountSecondPassword() {
        return this.accountsecondPassword;
    }

    public void openNpc(int id) {
        this.openNpc(id, null);
    }

    public void openPartyNpc(MapleCharacter c, int id, String bossid) {
        if (c.getParty() == null || c.getParty().getMembers().size() == 1) {
            c.openNpc(id, bossid);
            return;
        }
        for (MaplePartyCharacter chr : c.getParty().getMembers()) {
            MapleCharacter curChar = c.getMap().getCharacterById(chr.getId());
            if (curChar != null) {
                curChar.openNpc(id, bossid);
            }
        }
    }

    public void setPartyAccountidLog(MapleCharacter c, String log1, int slot) {
        if (c.getParty() == null || c.getParty().getMembers().size() == 1) {
            c.setAccountidLog(log1, slot);
            return;
        }
        for (MaplePartyCharacter chr : c.getParty().getMembers()) {
            MapleCharacter curChar = c.getMap().getCharacterById(chr.getId());
            if (curChar != null) {
                curChar.setAccountidLog(log1, slot);
            }
        }
    }

    public void openNpc(int id, String mode) {
        this.getClient().removeClickedNPC();
        NPCScriptManager.getInstance().dispose(this.getClient());
        NPCScriptManager.getInstance().start(this.getClient(), id, mode);
    }

    public int getOneWeekLog(String log1) {
        int jf = 0;
        PreparedStatement ps = null;
        PreparedStatement psu = null;
        ResultSet rs = null;
        try (Connection con = BeePool.getConnection()) {
            ps = con.prepareStatement("select * from onetimelogd where characterid =? and log = ?");
            ps.setInt(1, this.id);
            ps.setString(2, log1);
            rs = ps.executeQuery();
            if (rs.next()) {
                jf = rs.getInt("sz1");
            } else {
                psu = con.prepareStatement("insert into onetimelogd (characterid,log, sz1) VALUES (?,?, ?)");
                psu.setInt(1, this.id);
                psu.setString(2, log1);
                psu.setInt(3, 0);
                psu.executeUpdate();
                psu.close();
            }
            rs.close();
            ps.close();
            
        } catch (SQLException ex) {
            System.err.println("onetimelogd读取发生错误: " + ex);
        }
        return jf;
    }

    public void setOneWeekLog(String boss) {
        this.setOneWeekLog(boss, 1);
    }

    public void setOneWeekLog(String boss, int count) {
        int bossCount = this.getOneWeekLog(boss);
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = con.prepareStatement("UPDATE onetimelogd SET sz1 = ? WHERE characterid = ? AND log = ?");
            ps.setInt(1, bossCount + count);
            ps.setInt(2, this.id);
            ps.setString(3, boss);
            ps.executeUpdate();
            ps.close();
            
        } catch (Exception Ex) {
            System.err.println("onetimelogd读取发生错误: " + Ex);
        }
    }

    public int getBossLog1(String boss) {
        return this.getBossLog1(boss, 0);
    }

    public int getBossLog1(String boss, int type) {
        try (Connection con = BeePool.getConnection()) {
            int count = 0;
            PreparedStatement ps = con.prepareStatement("SELECT * FROM bosslog1 WHERE characterid = ? AND bossid = ?");
            ps.setInt(1, this.id);
            ps.setString(2, boss);
            ResultSet rs = ps.executeQuery();
            if (rs.next()) {
                count = rs.getInt("count");
                Timestamp bossTime = rs.getTimestamp("time");
                if (type == 0) {
                    if (bossTime != null) {
                        Calendar cal = Calendar.getInstance();
                        cal.setTimeInMillis(bossTime.getTime());
                        if (cal.get(5) + 1 <= Calendar.getInstance().get(5) || cal.get(2) + 1 <= Calendar.getInstance().get(2)) {
                            count = 0;
                            PreparedStatement psa = con.prepareStatement("UPDATE bosslog1 SET count = 0  WHERE characterid = ? AND bossid = ?");
                            psa.setInt(1, this.id);
                            psa.setString(2, boss);
                            psa.executeUpdate();
                            psa.close();
                        }
                    }
                    PreparedStatement psa2 = con.prepareStatement("UPDATE bosslog1 SET time = CURRENT_TIMESTAMP() WHERE characterid = ? AND bossid = ?");
                    psa2.setInt(1, this.id);
                    psa2.setString(2, boss);
                    psa2.executeUpdate();
                    psa2.close();
                }
            } else {
                PreparedStatement psu = con.prepareStatement("INSERT INTO bosslog1 (characterid, bossid, count, type) VALUES (?, ?, ?, ?)");
                psu.setInt(1, this.id);
                psu.setString(2, boss);
                psu.setInt(3, 0);
                psu.setInt(4, type);
                psu.executeUpdate();
                psu.close();
            }
            rs.close();
            ps.close();
            
            return count;
        } catch (Exception ex) {
            return -1;
        }
    }

    public void setBossLog1(String boss) {
        this.setBossLog1(boss, 0);
    }

    public void setBossLog1(String boss, int type) {
        this.setBossLog1(boss, type, 1);
    }

    public void setBossLog1(String boss, int type, int count) {
        int bossCount = this.getBossLog1(boss, type);
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = con.prepareStatement("UPDATE bosslog1 SET count = ?, type = ?, time = CURRENT_TIMESTAMP() WHERE characterid = ? AND bossid = ?");
            ps.setInt(1, bossCount + count);
            ps.setInt(2, type);
            ps.setInt(3, this.id);
            ps.setString(4, boss);
            ps.executeUpdate();
            ps.close();
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }

    public int getAccountidLog(String log1) {
        int jf = 0;
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = con.prepareStatement("select * from accountidlog where id =? and log = ?");
            ps.setInt(1, this.accountid);
            ps.setString(2, log1);
            ResultSet rs = ps.executeQuery();
            if (rs.next()) {
                jf = rs.getInt("sz1");
            } else {
                PreparedStatement psu = con.prepareStatement("insert into accountidlog (id,log, sz1) VALUES (?,?, ?)");
                psu.setInt(1, this.accountid);
                psu.setString(2, log1);
                psu.setInt(3, 0);
                psu.executeUpdate();
                psu.close();
            }
            rs.close();
            ps.close();
            
        } catch (SQLException ex) {
            System.err.println("FZ3读取发生错误: " + ex);
        }
        return jf;
    }

    public void setAccountidLog(String log1) {
        this.setAccountidLog(log1, 1);
    }

    public void setAccountidLog(String log1, int slot) {
        int jf = this.getAccountidLog(log1);
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = con.prepareStatement("UPDATE accountidlog SET sz1 = ? where id = ? AND log = ?");
            ps.setInt(1, jf + slot);
            ps.setInt(2, this.accountid);
            ps.setString(3, log1);
            ps.executeUpdate();
            ps.close();
            
        } catch (SQLException ex) {
            System.err.println("FZ3加减发生错误: " + ex);
        }
    }

    public int getAccountLog(String log1, int a) {
        if (a < 1) {
            return this.getAccountidBossLog(log1);
        }
        return this.getAccountidLog(log1);
    }

    public void setAccountLog(String log1, int a) {
        if (a < 1) {
            this.setAccountidBossLog(log1, 1);
        } else {
            this.setAccountidLog(log1, 1);
        }
    }

    public void setAccountLog(String log1, int a, int b) {
        if (a < 1) {
            this.setAccountidBossLog(log1, b);
        } else {
            this.setAccountidLog(log1, b);
        }
    }

    public int getAccountidBossLog(String log1) {
        int jf = 0;
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = con.prepareStatement("select * from accountidbosslog where id =? and log = ?");
            ps.setInt(1, this.accountid);
            ps.setString(2, log1);
            ResultSet rs = ps.executeQuery();
            if (rs.next()) {
                jf = rs.getInt("sz1");
            } else {
                PreparedStatement psu = con.prepareStatement("insert into accountidbosslog (id,log, sz1) VALUES (?,?, ?)");
                psu.setInt(1, this.accountid);
                psu.setString(2, log1);
                psu.setInt(3, 0);
                psu.executeUpdate();
                psu.close();
            }
            rs.close();
            ps.close();
            
        } catch (SQLException ex) {
            System.err.println("FZ3读取发生错误: " + ex);
        }
        return jf;
    }

    public void setAccountidBossLog(String log1) {
        this.setAccountidBossLog(log1, 1);
    }

    public void setAccountidBossLog(String log1, int slot) {
        int jf = this.getAccountidBossLog(log1);
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = con.prepareStatement("UPDATE accountidbosslog SET sz1 = ? where id = ? AND log = ?");
            ps.setInt(1, jf + slot);
            ps.setInt(2, this.accountid);
            ps.setString(3, log1);
            ps.executeUpdate();
            ps.close();
        } catch (SQLException ex) {
            System.err.println("accountidbosslog加减发生错误: " + ex);
        }
    }

    public int getFZ4(String log1) {
        int jf = 0;
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = con.prepareStatement("select * from fz4 where log = ?");
            ps.setString(1, log1);
            ResultSet rs = ps.executeQuery();
            if (rs.next()) {
                jf = rs.getInt("sz1");
            } else {
                PreparedStatement psu = con.prepareStatement("insert into fz4 (log, sz1) VALUES (?, ?)");
                psu.setString(1, log1);
                jf = 0;
                psu.setInt(2, 0);
                psu.executeUpdate();
                psu.close();
            }
            rs.close();
            ps.close();
        } catch (SQLException ex) {
            System.err.println("FZ4读取发生错误: " + ex);
        }
        return jf;
    }

    public void setFZ4(String name, int value) {
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = null;
            ps = con.prepareStatement("UPDATE fz4 SET sz1 = ? WHERE log = ?");
            ps.setInt(1, value);
            ps.setString(2, name);
            ps.execute();
            ps.close();
        } catch (SQLException ex) {
            System.err.println("FZ4更新发生错误: " + ex);
        }
    }

    public static int getFZ9(String log1) {
        int jf = 0;
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = con.prepareStatement("select * from fz9 where log = ?");
            ps.setString(1, log1);
            ResultSet rs = ps.executeQuery();
            if (rs.next()) {
                jf = rs.getInt("sz1");
            } else {
                PreparedStatement psu = con.prepareStatement("insert into fz9 (log, sz1) VALUES (?, ?)");
                psu.setString(1, log1);
                jf = 50;
                psu.setInt(2, 50);
                psu.executeUpdate();
                psu.close();
            }
            rs.close();
            ps.close();
        } catch (SQLException ex) {
            System.err.println("FZ9读取发生错误: " + ex);
        }
        return jf;
    }

    public int getFZ3modid(int someid, String log1) {
        int jf = 0;
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = con.prepareStatement("select * from fz3 where cid = ? AND log = ?");
            ps.setInt(1, someid);
            ps.setString(2, log1);
            ResultSet rs = ps.executeQuery();
            if (rs.next()) {
                jf = rs.getInt("sz1");
            } else {
                PreparedStatement psu = con.prepareStatement("insert into fz3 (cid,log, sz1,sz2) VALUES (?, ?, ?,?)");
                psu.setInt(1, someid);
                psu.setString(2, log1);
                psu.setInt(3, 0);
                psu.setInt(4, 0);
                psu.executeUpdate();
                psu.close();
            }
            rs.close();
            ps.close();
        } catch (SQLException ex) {
            System.err.println("FZ3读取发生错误: " + ex);
        }
        return jf;
    }

    public int getFZ3slid(int someid, String log1) {
        int jf = 0;
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = con.prepareStatement("select * from fz3 where cid = ? AND log = ?");
            ps.setInt(1, someid);
            ps.setString(2, log1);
            ResultSet rs = ps.executeQuery();
            if (rs.next()) {
                jf = rs.getInt("sz2");
            } else {
                PreparedStatement psu = con.prepareStatement("insert into fz3 (cid,log, sz1,sz2) VALUES (?, ?, ?,?)");
                psu.setInt(1, someid);
                psu.setString(2, log1);
                psu.setInt(3, 0);
                psu.setInt(4, 0);
                psu.executeUpdate();
                psu.close();
            }
            rs.close();
            ps.close();
        } catch (SQLException ex) {
            System.err.println("FZ3读取发生错误: " + ex);
        }
        return jf;
    }

    public int setFZ3modid(int someid, String log1, int slot) {
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = con.prepareStatement("UPDATE fz3 SET sz1 = ? where cid = ? AND log = ?");
            ps.setInt(1, slot);
            ps.setInt(2, someid);
            ps.setString(3, log1);
            ps.executeUpdate();
            ps.close();
            
            return 1;
        } catch (SQLException ex) {
            System.err.println("FZ3加减发生错误: " + ex);
            return 0;
        }
    }

    public int setFZ3slid(int someid, String log1, int slot) {
        int jf = this.getFZ3slid(someid, log1);
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = con.prepareStatement("UPDATE fz3 SET sz2 = ? where cid = ? AND log = ? ");
            ps.setInt(1, slot + jf);
            ps.setInt(2, someid);
            ps.setString(3, log1);
            ps.executeUpdate();
            ps.close();
            
            return 1;
        } catch (SQLException ex) {
            System.err.println("FZ3加减发生错误: " + ex);
            return 0;
        }
    }

    public int reaFZ3slid(int someid, String log1) {
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = con.prepareStatement("UPDATE fz3 SET sz2 = ? AND sz2 = ?where cid = ? AND log = ?");
            ps.setInt(1, 0);
            ps.setInt(2, 0);
            ps.setInt(3, someid);
            ps.setString(4, log1);
            ps.executeUpdate();
            ps.close();
            
            return 1;
        } catch (SQLException ex) {
            System.err.println("FZ3加减发生错误: " + ex);
            return 0;
        }
    }

    public int getAccNewTime(String time) {
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = con.prepareStatement("select count(*) from accounts where id = ? and createdat <= '" + time + "'");
            ps.setInt(1, this.accountid);
            int ret_count;
            try (ResultSet rs = ps.executeQuery()) {
                if (rs.next()) {
                    ret_count = rs.getInt(1);
                } else {
                    ret_count = -1;
                }
                rs.close();
            }
            ps.close();
            
            return ret_count;
        } catch (Exception Ex) {
            FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) Ex);
            return -1;
        }
    }

    public int getAddLog() {
        try (Connection con = BeePool.getConnection()) {
            int money = 0;
            PreparedStatement ps = con.prepareStatement("SELECT money FROM addlog WHERE accid = ?");
            ps.setInt(1, this.getClient().getAccID());
            ResultSet rs = ps.executeQuery();
            while (rs.next()) {
                money += rs.getInt("money");
            }
            rs.close();
            ps.close();
            
            return money;
        } catch (SQLException e) {
            FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) e);
            return -1;
        }
    }

    public void setPrizeLog(String bossid) {
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = con.prepareStatement("insert into Prizelog (accid, bossid) values (?,?)");
            ps.setInt(1, this.getClient().getAccID());
            ps.setString(2, bossid);
            ps.executeUpdate();
            ps.close();
            
        } catch (Exception Wx) {
            FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) Wx);
        }
    }

    public int getPrizeLog(String bossid) {
        try (Connection con = BeePool.getConnection()) {
            int ret_count = 0;
            PreparedStatement ps = con.prepareStatement("select count(*) from Prizelog where accid = ? and bossid = ?");
            ps.setInt(1, this.getClient().getAccID());
            ps.setString(2, bossid);
            ResultSet rs = ps.executeQuery();
            if (rs.next()) {
                ret_count = rs.getInt(1);
            } else {
                ret_count = -1;
            }
            rs.close();
            ps.close();
            
            return ret_count;
        } catch (Exception Wx) {
            FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) Wx);
            return -1;
        }
    }

    public void setAcLog(String bossid) {
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = con.prepareStatement("insert into Aclog (accid, bossid) values (?,?)");
            ps.setInt(1, this.getClient().getAccID());
            ps.setString(2, bossid);
            ps.executeUpdate();
            ps.close();
            
        } catch (Exception Wx) {
            FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) Wx);
        }
    }

    public void setAcLogS(String bossid) {
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = con.prepareStatement("insert into Aclog (accid, bossid) values (?,?)");
            ps.setInt(1, this.getAccountID());
            ps.setString(2, bossid);
            ps.executeUpdate();
            ps.close();
            
        } catch (Exception Wx) {
            FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) Wx);
        }
    }

    public int getAcLog(String bossid) {
        try (Connection con = BeePool.getConnection()) {
            int ret_count = 0;
            PreparedStatement ps = con.prepareStatement("select count(*) from Aclog where accid = ? and bossid = ? and lastattempt >= subtime(current_timestamp, '1 0:0:0.0')");
            ps.setInt(1, this.getClient().getAccID());
            ps.setString(2, bossid);
            ResultSet rs = ps.executeQuery();
            if (rs.next()) {
                ret_count = rs.getInt(1);
            } else {
                ret_count = -1;
            }
            rs.close();
            ps.close();
            
            return ret_count;
        } catch (Exception Wx) {
            FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) Wx);
            return -1;
        }
    }

    public int getAcLogS(String bossid) {
        try (Connection con = BeePool.getConnection()) {
            int ret_count = 0;
            PreparedStatement ps = con.prepareStatement("select count(*) from Aclog where accid = ? and bossid = ?");
            ps.setInt(1, this.getClient().getAccID());
            ps.setString(2, bossid);
            ResultSet rs = ps.executeQuery();
            if (rs.next()) {
                ret_count = rs.getInt(1);
            } else {
                ret_count = -1;
            }
            rs.close();
            ps.close();
            
            return ret_count;
        } catch (Exception Wx) {
            FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) Wx);
            return -1;
        }
    }

    public void dropMessage(int type, String message) {
        if (type == -1) {
            this.client.sendPacket(UIPacket.getTopMsg(message));
        } else if (type == -2) {
            this.client.sendPacket(PlayerShopPacket.shopChat(message, 0));
        } else if (type == -11) {
            this.client.getSession().writeAndFlush(MaplePacketCreator.yellowChat(message));
        } else {
            this.client.sendPacket(MaplePacketCreator.serverNotice(type, message));
        }
    }

    public void showInfo(String caption, boolean pink, String msg) {
        short type = (short) (pink ? 5 : 6);
        if (caption != null && !caption.isEmpty()) {
            msg = "[" + caption + "] " + msg;
        }
        this.dropMessage((int) type, msg);
        this.dropMessage(-1, msg);
    }

    public IMaplePlayerShop getPlayerShop() {
        return this.playerShop;
    }

    public void setPlayerShop(IMaplePlayerShop playerShop) {
        this.playerShop = playerShop;
    }

    public int getConversation() {
        return this.inst.get();
    }

    public void setConversation(int inst) {
        this.inst.set(inst);
    }

    public MapleCarnivalParty getCarnivalParty() {
        return this.carnivalParty;
    }

    public void setCarnivalParty(MapleCarnivalParty party) {
        this.carnivalParty = party;
    }

    public void addCP(int ammount) {
        this.totalCP += (short) ammount;
        this.availableCP += (short) ammount;
    }

    public void useCP(int ammount) {
        if (this.availableCP >= ammount) {
            this.availableCP -= (short) ammount;
        }
    }

    public int getAvailableCP() {
        return this.availableCP;
    }

    public int getTotalCP() {
        return this.totalCP;
    }

    public void resetCP() {
        this.totalCP = 0;
        this.availableCP = 0;
    }

    public static int getIdByName(String name) {
        try {
            int id = -1;
            try (Connection con = BeePool.getConnection();
                 PreparedStatement ps = con.prepareStatement("SELECT id FROM characters WHERE name = ?")) {
                ps.setString(1, name);
                try (ResultSet rs = ps.executeQuery()) {
                    if (rs.next()) {
                        id = rs.getInt("id");
                    }
                }
                ps.close();
            }
            return id;
        } catch (Exception e) {
            System.err.println("错误 'getIdByName' " + e);
            FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) e);
            return -1;
        }
    }

    public void addCarnivalRequest(MapleCarnivalChallenge request) {
        this.pendingCarnivalRequests.add(request);
    }

    public MapleCarnivalChallenge getNextCarnivalRequest() {
        return (MapleCarnivalChallenge) this.pendingCarnivalRequests.pollLast();
    }

    public void clearCarnivalRequests() {
        this.pendingCarnivalRequests = (Deque<MapleCarnivalChallenge>) new LinkedList();
    }

    public void startMonsterCarnival(int enemyavailable, int enemytotal) {
        this.client.sendPacket(MonsterCarnivalPacket.startMonsterCarnival(this, enemyavailable, enemytotal));
    }

    public void CPUpdate(boolean party, int available, int total, int team) {
        this.client.sendPacket(MonsterCarnivalPacket.CPUpdate(party, available, total, team));
    }

    public void playerDiedCPQ(String name, int lostCP, int team) {
        this.client.sendPacket(MonsterCarnivalPacket.playerDiedMessage(name, lostCP, team));
    }

    public boolean getCanTalk() {
        return this.canTalk;
    }

    public void canTalk(boolean talk) {
        this.canTalk = talk;
    }

    public int getEXPMod() {
        return this.stats.expMod;
    }

    public int getDropMod() {
        return this.stats.dropMod;
    }

    public double getDropm() {
        return this.stats.dropm;
    }

    public double getExpm() {
        return this.stats.expm;
    }

    public int getCashMod() {
        return this.stats.cashMod;
    }

    public int getCloneDamgeRate() {
        return this.clonedamgerate;
    }

    public void setCloneDamgeRate(int a) {
        this.clonedamgerate = a;
    }

    public void setVPoints(int p) {
        this.vpoints = p;
    }

    public int getVPoints() {
        return this.vpoints;
    }

    public CashShop getCashInventory() {
        return this.cs;
    }

    public void removeAll(int id) {
        this.removeAll(id, false);
    }

    public void removeAll(int id, boolean show) {
        this.removeAll(id, false, false);
    }

    public void removeAll(int id, boolean show, boolean equip) {
        MapleInventoryType type = GameConstants.getInventoryType(id);
        int possessed = this.getInventory(type).countById(id);
        if (possessed > 0) {
            MapleInventoryManipulator.removeById(this.getClient(), type, id, possessed, true, false);
            if (show) {
                this.getClient().sendPacket(MaplePacketCreator.getShowItemGain(id, (short) (-possessed), true));
            }
        }
        if (equip && type == MapleInventoryType.EQUIP) {
            type = MapleInventoryType.EQUIPPED;
            possessed = this.getInventory(type).countById(id);
            if (possessed > 0) {
                MapleInventoryManipulator.removeById(this.getClient(), type, id, possessed, true, false);
                this.getClient().sendPacket(MaplePacketCreator.getShowItemGain(id, (short) (-possessed), true));
            }
        }
    }

    public MapleRing getMarriageRing(boolean incluedEquip) {
        MapleInventory iv = this.getInventory(MapleInventoryType.EQUIPPED);
        Collection<IItem> equippedC = iv.list();
        List<Item> equipped = (List<Item>) new ArrayList(equippedC.size());
        for (IItem item : equippedC) {
            equipped.add((Item) item);
        }
        for (Item item2 : equipped) {
            if (item2.getRing() != null) {
                MapleRing ring = item2.getRing();
                ring.setEquipped(true);
                if (GameConstants.isMarriageRing(item2.getItemId())) {
                    return ring;
                }
                continue;
            }
        }
        if (incluedEquip) {
            iv = this.getInventory(MapleInventoryType.EQUIP);
            for (IItem item : iv.list()) {
                if (item.getRing() != null && GameConstants.isMarriageRing(item.getItemId())) {
                    MapleRing ring = item.getRing();
                    ring.setEquipped(false);
                    return ring;
                }
            }
        }
        return null;
    }

    public Pair<List<MapleRing>, List<MapleRing>> getRings(boolean equip) {
        MapleInventory iv = this.getInventory(MapleInventoryType.EQUIPPED);
        Collection<IItem> equippedC = iv.list();
        List<Item> equipped = (List<Item>) new ArrayList(equippedC.size());
        for (IItem item : equippedC) {
            equipped.add((Item) item);
        }
        Collections.sort(equipped);
        List<MapleRing> crings = (List<MapleRing>) new ArrayList();
        List<MapleRing> frings = (List<MapleRing>) new ArrayList();
        for (Item item2 : equipped) {
            if (item2.getRing() != null) {
                MapleRing ring = item2.getRing();
                ring.setEquipped(true);
                if (!GameConstants.isEffectRing(item2.getItemId())) {
                    continue;
                }
                if (equip) {
                    if (GameConstants.isCrushRing(item2.getItemId())) {
                        crings.add(ring);
                    } else {
                        if (!GameConstants.isFriendshipRing(item2.getItemId())) {
                            continue;
                        }
                        frings.add(ring);
                    }
                } else if (crings.isEmpty() && GameConstants.isCrushRing(item2.getItemId())) {
                    crings.add(ring);
                } else {
                    if (!frings.isEmpty() || !GameConstants.isFriendshipRing(item2.getItemId())) {
                        continue;
                    }
                    frings.add(ring);
                }
            }
        }
        if (equip) {
            iv = this.getInventory(MapleInventoryType.EQUIP);
            for (IItem item3 : iv.list()) {
                if (item3.getRing() != null && GameConstants.isEffectRing(item3.getItemId())) {
                    MapleRing ring = item3.getRing();
                    ring.setEquipped(false);
                    if (GameConstants.isFriendshipRing(item3.getItemId())) {
                        frings.add(ring);
                    } else {
                        if (!GameConstants.isCrushRing(item3.getItemId())) {
                            continue;
                        }
                        crings.add(ring);
                    }
                }
            }
        }
        Collections.sort(frings, new RingComparator());
        Collections.sort(crings, new RingComparator());
        return new Pair(crings, frings);
    }

    public int getFH() {
        MapleFoothold fh = this.getMap().getFootholds().findBelow(this.getPosition());
        if (fh != null) {
            return fh.getId();
        }
        return 0;
    }

    public void startFairySchedule(boolean exp) {
        this.startFairySchedule(exp, false);
    }

    public void startFairySchedule(boolean exp, boolean equipped) {
        try {
            this.cancelFairySchedule(exp);
            if (this.fairyExp < 30 && this.stats.equippedFairy) {
                if (equipped) {
                    this.dropMessage(5, "您装备了精灵吊坠在1小时后经验获取将增加到 " + (this.fairyExp + 10) + "%");
                }
                this.fairySchedule = EtcTimer.getInstance().schedule((Runnable) new Runnable() {
                    @Override
                    public void run() {
                        if (MapleCharacter.this.fairyExp < 30 && MapleCharacter.this.stats.equippedFairy) {
                            MapleCharacter.this.fairyExp = (byte) 30;
                            ++MapleCharacter.this.fairyHour;
                            MapleCharacter.this.dropMessage(5, "因装备精灵坠饰经过了" + (int) MapleCharacter.this.fairyHour + "小时，打怪时可以额外获得红利经验值" + (int) MapleCharacter.this.fairyExp + "%.");
                            MapleCharacter.this.startFairySchedule(false, true);
                        } else {
                            MapleCharacter.this.cancelFairySchedule(!MapleCharacter.this.stats.equippedFairy);
                        }
                    }
                }, 3600000L);
            } else {
                this.cancelFairySchedule(!this.stats.equippedFairy);
            }
        } catch (RejectedExecutionException ex) {
        }
    }

    public void cancelFairySchedule(boolean exp) {
        if (this.fairySchedule != null) {
            this.fairySchedule.cancel(false);
            this.fairySchedule = null;
        }
        if (exp) {
            this.fairyExp = 30;
            this.fairyHour = 1;
        }
    }

    public byte getFairyExp() {
        return this.fairyExp;
    }

    public void setFairyExp(byte Exp) {
        this.fairyExp = Exp;
    }

    public int getCoconutTeam() {
        return this.coconutteam;
    }

    public void setCoconutTeam(int team) {
        this.coconutteam = team;
    }

    public void spawnPet(byte slot) {
        this.spawnPet(slot, false, true);
    }

    public void spawnPet(byte slot, boolean lead) {
        this.spawnPet(slot, lead, true);
        boolean 宠物buff开关 = Boolean.parseBoolean(ServerProperties.getProperty("cc.宠物buff开关"));
        boolean 宠物特殊buff开关 = Boolean.parseBoolean(ServerProperties.getProperty("cc.宠物特殊buff开关"));
        boolean 宠物基础buff开关 = Boolean.parseBoolean(ServerProperties.getProperty("cc.宠物基础buff开关"));
        String[] 特殊宠物代码 = ServerProperties.getProperty("cc.特殊宠物代码").split(",");
        boolean 特殊宠物开关 = false;
        if (宠物buff开关) {
            for (int i = 0; i < 特殊宠物代码.length; ++i) {
                if (this.getInventory(MapleInventoryType.CASH).getItem((short) slot).getItemId() == Integer.parseInt(特殊宠物代码[i])) {
                    特殊宠物开关 = true;
                }
            }
            if (特殊宠物开关) {
                if (宠物特殊buff开关) {
                    MapleItemInformationProvider.getInstance().getItemEffect1(2001517).applyTo(this.client.getPlayer());
                }
            } else if (宠物基础buff开关) {
                MapleItemInformationProvider.getInstance().getItemEffect1(2001519).applyTo(this.client.getPlayer());
            }
        }
    }

    public void removeFromSlot(int type, short slot, short number) {
        MapleInventoryType a = MapleInventoryType.EQUIP;
        if (type == 1) {
            a = MapleInventoryType.EQUIP;
        } else if (type == 2) {
            a = MapleInventoryType.USE;
        } else if (type == 3) {
            a = MapleInventoryType.SETUP;
        } else if (type == 4) {
            a = MapleInventoryType.ETC;
        } else if (type == 5) {
            a = MapleInventoryType.CASH;
        }
        MapleInventoryManipulator.removeFromSlot(this.client, a, slot, number, false);
    }

    public void addFromDrop(IItem item, boolean a) {
        MapleInventoryManipulator.addFromDrop(this.client, item, a);
    }

    public void spawnPet(byte slot, boolean lead, boolean broadcast) {
        IItem item = this.getInventory(MapleInventoryType.CASH).getItem((short) slot);
        MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
        if (item == null || item.getItemId() > 5010000 || item.getItemId() < 5000000) {
            return;
        }
        switch (item.getItemId()) {
            case 5000028:
            case 5000047: {
                MaplePet pet = MaplePet.createPet(item.getItemId() + 1, MapleInventoryIdentifier.getInstance());
                if (pet != null) {
                    MapleInventoryManipulator.addById(this.client, item.getItemId() + 1, (short) 1, item.getOwner(), pet, 45L);
                    MapleInventoryManipulator.removeFromSlot(this.client, MapleInventoryType.CASH, (short) slot, (short) 1, false);
                    break;
                }
                break;
            }
            default: {
                MaplePet pet = item.getPet();
                if (pet == null || (item.getItemId() == 5000054 && pet.getSecondsLeft() <= 0) || (item.getExpiration() != -1L && item.getExpiration() <= System.currentTimeMillis())) {
                    break;
                }
                if (pet.getSummoned()) {
                    this.unequipPet(pet, false);
                    break;
                }
                int leadid = 8;
                if (GameConstants.isKOC((int) this.getJob())) {
                    leadid = 10000018;
                } else if (GameConstants.isAran((int) this.getJob())) {
                    leadid = 20000024;
                }
                if (this.getSkillLevel(SkillFactory.getSkill(leadid)) == 0 && this.getSummonedPet(0) != null) {
                    this.unequipPet(this.getSummonedPet(0), false);
                } else if (lead) {
                    this.shiftPetsRight();
                }
                Point pos = this.getPosition();
                pet.setPos(pos);
                try {
                    pet.setFh(this.getMap().getFootholds().findBelow(pos).getId());
                } catch (NullPointerException e) {
                    pet.setFh(0);
                }
                pet.setStance(0);
                pet.setSummoned(this.getPetSlotNext() + 1);
                this.addPet(pet);
                if (this.getMap() != null) {
                    this.getMap().broadcastMessage(this, PetPacket.showPet(this, pet, false, false), true);
                    this.client.sendPacket(PetPacket.loadExceptionList(this, pet));
                    this.client.sendPacket(PetPacket.petStatUpdate(this));
                }
                break;
            }
        }
        this.client.sendPacket(PetPacket.emptyStatUpdate());
    }

    public void addMoveMob(int mobid) {
        if (this.movedMobs.containsKey(Integer.valueOf(mobid))) {
            this.movedMobs.put(Integer.valueOf(mobid), Integer.valueOf(((Integer) this.movedMobs.get(Integer.valueOf(mobid))).intValue() + 1));
            if (((Integer) this.movedMobs.get(Integer.valueOf(mobid))).intValue() > 30) {
                for (MapleCharacter chr : this.getMap().getCharactersThreadsafe()) {
                    if (chr.getMoveMobs().containsKey(Integer.valueOf(mobid))) {
                        chr.getClient().sendPacket(MobPacket.killMonster(mobid, 1));
                        chr.getMoveMobs().remove(Integer.valueOf(mobid));
                    }
                }
            }
        } else {
            this.movedMobs.put(Integer.valueOf(mobid), Integer.valueOf(1));
        }
    }

    public Map<Integer, Integer> getMoveMobs() {
        return this.movedMobs;
    }

    public int getLinkMid() {
        return this.linkMid;
    }

    public void setLinkMid(int lm) {
        this.linkMid = lm;
    }

    public boolean isClone() {
        return this.clone;
    }

    public void setClone(boolean c) {
        this.clone = c;
    }

    public WeakReference<MapleCharacter>[] getClones() {
        return this.clones;
    }

    public MapleCharacter cloneLooks() {
        MapleClient cloneClient = new MapleClient(null, null, (Channel) new MockIOSession());
        int minus = this.getId() + Randomizer.nextInt(this.getId());
        MapleCharacter ret = new MapleCharacter(true);
        ret.id = minus;
        ret.client = cloneClient;
        ret.exp = 0;
        ret.meso = 0;
        ret.beans = this.beans;
        ret.blood = this.blood;
        ret.month = this.month;
        ret.day = this.day;
        ret.charmessage = this.charmessage;
        ret.expression = this.expression;
        ret.constellation = this.constellation;
        ret.remainingAp = 0;
        ret.fame = 0;
        ret.accountid = this.client.getAccID();
        ret.name = this.name;
        ret.level = this.level;
        ret.fame = this.fame;
        ret.job = this.job;
        ret.hair = this.hair;
        ret.face = this.face;
        ret.skinColor = this.skinColor;
        ret.bookCover = this.bookCover;
        ret.monsterbook = this.monsterbook;
        ret.mount = this.mount;
        ret.CRand = new PlayerRandomStream();
        ret.gmLevel = this.gmLevel;
        ret.gender = this.gender;
        ret.mapid = this.map.getId();
        ret.map = this.map;
        ret.setStance(this.getStance());
        ret.chair = this.chair;
        ret.itemEffect = this.itemEffect;
        ret.guildid = this.guildid;
        ret.currentrep = this.currentrep;
        ret.totalrep = this.totalrep;
        ret.stats = this.stats;
        ret.limitBreak = this.limitBreak;
        ret.reinNumber = this.reinNumber;
        ret.effects.putAll(this.effects);
        if (ret.effects.get(MapleBuffStat.ILLUSION) != null) {
            ret.effects.remove(MapleBuffStat.ILLUSION);
        }
        if (ret.effects.get(MapleBuffStat.SUMMON) != null) {
            ret.effects.remove(MapleBuffStat.SUMMON);
        }
        if (ret.effects.get(MapleBuffStat.PUPPET) != null) {
            ret.effects.remove(MapleBuffStat.PUPPET);
        }
        ret.guildrank = this.guildrank;
        ret.allianceRank = this.allianceRank;
        ret.hidden = this.hidden;
        ret.setPosition(new Point(this.getPosition()));
        for (IItem equip : this.getInventory(MapleInventoryType.EQUIPPED)) {
            ret.getInventory(MapleInventoryType.EQUIPPED).addFromDB(equip);
        }
        ret.skillMacros = this.skillMacros;
        ret.keylayout = this.keylayout;
        ret.questinfo = this.questinfo;
        ret.savedLocations = this.savedLocations;
        ret.wishlist = this.wishlist;
        ret.rocks = this.rocks;
        ret.regrocks = this.regrocks;
        ret.buddylist = this.buddylist;
        ret.keydown_skill = 0L;
        ret.lastmonthfameids = this.lastmonthfameids;
        ret.lastfametime = this.lastfametime;
        ret.storage = this.storage;
        ret.cs = this.cs;
        ret.client.setAccountName(this.client.getAccountName());
        ret.maplepoints = this.maplepoints;
        ret.clone = true;
        ret.client.setChannel(this.client.getChannel());
        while (this.map.getCharacterById(ret.id) != null || this.client.getChannelServer().getPlayerStorage().getCharacterById(ret.id) != null) {
            MapleCharacter mapleCharacter = ret;
            ++mapleCharacter.id;
        }
        ret.client.setPlayer(ret);
        return ret;
    }

    public void cloneLook() {
        this.cloneLook(false, null, null);
    }

    public void cloneLook(boolean isStopMoving) {
        this.cloneLook(isStopMoving, null, null);
    }

    public void cloneLook(MapleCharacter look) {
        this.cloneLook(false, look, null);
    }

    public void cloneLook(boolean isStopMoving, MapleCharacter look) {
        this.cloneLook(isStopMoving, look, null);
    }

    public boolean isStopMoving() {
        return this.stopMoving;
    }

    public void setStopMoving(boolean stopMoving) {
        this.stopMoving = stopMoving;
    }

    public void cloneLook(boolean isStopMoving, MapleCharacter look, String name) {
        if (this.clone) {
            return;
        }
        for (int i = 0; i < this.clones.length; ++i) {
            if (this.clones[i].get() == null) {
                MapleCharacter newp = (look == null) ? this.cloneLooks() : look;
                if (name != null) {
                    newp.setName(name);
                }
                this.map.addPlayer(newp);
                this.map.broadcastMessage(MaplePacketCreator.updateCharLook(newp));
                this.map.movePlayer(newp, this.getPosition());
                this.clones[i] = new WeakReference(newp);
                newp.setStopMoving(isStopMoving);
                return;
            }
        }
    }

    public void disposeClones() {
        this.numClones = 0;
        for (int i = 0; i < this.clones.length; ++i) {
            if (this.clones[i].get() != null) {
                this.map.removePlayer((MapleCharacter) this.clones[i].get());
                ((MapleCharacter) this.clones[i].get()).getClient().disconnect(false, false);
                this.clones[i] = new WeakReference(null);
                ++this.numClones;
            }
        }
    }

    public int getCloneSize() {
        int z = 0;
        for (WeakReference<MapleCharacter> clone1 : this.clones) {
            if (clone1.get() != null) {
                ++z;
            }
        }
        return z;
    }

    public void spawnClones() {
        if (this.numClones == 0 && this.stats.hasClone) {
            this.cloneLook();
        }
        for (int i = 0; i < this.numClones; ++i) {
            this.cloneLook();
        }
        this.numClones = 0;
    }

    public byte getNumClones() {
        return this.numClones;
    }

    public void spawnSavedPets() {
        for (int i = 0; i < this.petStore.length; ++i) {
            if (this.petStore[i] > -1) {
                this.spawnPet(this.petStore[i], false, false);
            }
        }
        this.client.sendPacket(PetPacket.petStatUpdate(this));
        this.petStore = new byte[]{-1, -1, -1};
    }

    public byte[] getPetStores() {
        return this.petStore;
    }

    public void resetStats(int str, int dex, int int_, int luk) {
        Map<MapleStat, Integer> statup = new EnumMap(MapleStat.class);
        int total = this.stats.getStr() + this.stats.getDex() + this.stats.getLuk() + this.stats.getInt() + this.getRemainingAp();
        total -= str;
        this.stats.setStr((short) str);
        total -= dex;
        this.stats.setDex((short) dex);
        total -= int_;
        this.stats.setInt((short) int_);
        total -= luk;
        this.stats.setLuk((short) luk);
        this.setRemainingAp((short) total);
        statup.put(MapleStat.STR, Integer.valueOf(str));
        statup.put(MapleStat.DEX, Integer.valueOf(dex));
        statup.put(MapleStat.INT, Integer.valueOf(int_));
        statup.put(MapleStat.LUK, Integer.valueOf(luk));
        statup.put(MapleStat.AVAILABLEAP, Integer.valueOf(total));
        this.client.sendPacket(MaplePacketCreator.updatePlayerStats(statup, false, this));
    }

    public Event_PyramidSubway getPyramidSubway() {
        return this.pyramidSubway;
    }

    public void setPyramidSubway(Event_PyramidSubway ps) {
        this.pyramidSubway = ps;
    }

    public byte getSubcategory() {
        if (this.job >= 430 && this.job <= 434) {
            return 1;
        }
        return this.subcategory;
    }

    public int itemQuantity(int itemid) {
        return this.getInventory(GameConstants.getInventoryType(itemid)).countById(itemid);
    }

    public void setRPS(RockPaperScissors rps) {
        this.rps = rps;
    }

    public RockPaperScissors getRPS() {
        return this.rps;
    }

    public long getNextConsume() {
        return this.nextConsume;
    }

    public void setNextConsume(long nc) {
        this.nextConsume = nc;
    }

    public int getRank() {
        return this.rank;
    }

    public int getRankMove() {
        return this.rankMove;
    }

    public int getJobRank() {
        return this.jobRank;
    }

    public int getJobRankMove() {
        return this.jobRankMove;
    }

    public void dispelBuff() {
        LinkedList<Entry<MapleBuffStat, MapleBuffStatValueHolder>> allBuffs = new LinkedList(this.effects.entrySet());
        for (Entry<MapleBuffStat, MapleBuffStatValueHolder> mbsvh : allBuffs) {
            long startTime = ((MapleBuffStatValueHolder) mbsvh.getValue()).startTime;
            long localDuration = (long) ((MapleBuffStatValueHolder) mbsvh.getValue()).localDuration;
            long nowtime = System.currentTimeMillis();
            if (startTime + localDuration - nowtime < 8000L) {
                this.dispelBuff(((MapleBuffStatValueHolder) mbsvh.getValue()).skillid);
            }
        }
    }

    public void ForcechangeChannel(int channel) {
        ChannelServer toch = ChannelServer.getInstance(channel);
        try {
            this.saveToDB(false, false);
        } catch (Exception ex) {
            FileoutputUtil.logToFile("logs/ForcechangeChannel保存数据异常.txt", "\r\n " + FileoutputUtil.NowTime() + " IP: " + this.getClient().getSession().remoteAddress().toString().split(":")[0] + " 账号 " + this.getClient().getAccountName() + " 账号ID " + this.getClient().getAccID() + " 角色名 " + this.getName() + " 角色ID " + this.getId());
            FileoutputUtil.outError("logs/ForcechangeChannel保存数据异常.txt", (Throwable) ex);
        }
        if (toch == null || toch.isShutdown()) {
            this.client.sendPacket(MaplePacketCreator.serverBlocked(1));
            return;
        }
        this.changeRemoval();
        this.dispelBuff();
        ChannelServer ch = ChannelServer.getInstance(this.client.getChannel());
        if (this.getMessenger() != null) {
            Messenger.silentLeaveMessenger(this.getMessenger().getId(), new MapleMessengerCharacter(this));
        }
        PlayerBuffStorage.addBuffsToStorage(this.getId(), this.getAllBuffs());
        PlayerBuffStorage.addCooldownsToStorage(this.getId(), this.getCooldowns());
        PlayerBuffStorage.addDiseaseToStorage(this.getId(), this.getAllDiseases());
        World.channelChangeData(new CharacterTransfer(this), this.getId(), channel);
        ch.removePlayer(this);
        this.client.updateLoginState(6, this.client.getSessionIPAddress());
        this.client.sendPacket(MaplePacketCreator.getChannelChange(this.client, Integer.parseInt(toch.getSocket().split(":")[1])));
        this.getMap().removePlayer(this);
        this.client.setPlayer(null);
        this.client.setReceiving(false);
    }

    public void changeChannel(int channel) {
        ChannelServer toch = ChannelServer.getInstance(channel);
        try {
            this.saveToDB(false, false);
        } catch (Exception ex) {
            FileoutputUtil.logToFile("logs/更换频道保存数据异常.txt", "\r\n " + FileoutputUtil.NowTime() + " IP: " + this.getClient().getSession().remoteAddress().toString().split(":")[0] + " 账号 " + this.getClient().getAccountName() + " 账号ID " + this.getClient().getAccID() + " 角色名 " + this.getName() + " 角色ID " + this.getId());
            FileoutputUtil.outError("logs/更换频道保存数据异常.txt", (Throwable) ex);
        }
        if (channel == this.client.getChannel() || toch == null || toch.isShutdown()) {
            this.client.sendPacket(MaplePacketCreator.serverBlocked(1));
            return;
        }
        this.dispelBuff();
        this.changeRemoval();
        ChannelServer ch = ChannelServer.getInstance(this.client.getChannel());
        if (this.getMessenger() != null) {
            Messenger.silentLeaveMessenger(this.getMessenger().getId(), new MapleMessengerCharacter(this));
        }
        PlayerBuffStorage.addBuffsToStorage(this.getId(), this.getAllBuffs());
        PlayerBuffStorage.addCooldownsToStorage(this.getId(), this.getCooldowns());
        PlayerBuffStorage.addDiseaseToStorage(this.getId(), this.getAllDiseases());
        World.channelChangeData(new CharacterTransfer(this), this.getId(), channel);
        if (ch != null) {
            ch.removePlayer(this);
        }
        this.client.updateLoginState(6, this.client.getSessionIPAddress());
        this.client.sendPacket(MaplePacketCreator.getChannelChange(this.client, Integer.parseInt(toch.getSocket().split(":")[1])));
        this.getMap().removePlayer(this);
        if (!LoginServer.CanLoginKey(this.getLoginKey(), this.getAccountID()) || (LoginServer.getLoginKey(this.getAccountID()) == null && !this.getLoginKey().isEmpty())) {
            FileoutputUtil.logToFile("logs/Data/客戶端登录KEY异常.txt", "\r\n " + FileoutputUtil.NowTime() + " IP: " + this.client.getSession().remoteAddress().toString().split(":")[0] + " 账号: " + this.client.getAccountName() + " 客戶端key：" + LoginServer.getLoginKey(this.getAccountID()) + " 服务端key：" + this.getLoginKey() + " 更换频道10");
            Broadcast.broadcastGMMessage(MaplePacketCreator.serverNotice(6, "[GM 密语系统] 非法更换频道 账号 " + this.client.getAccountName()));
            this.client.getSession().close();
            return;
        }
        if (!LoginServer.CanServerKey(this.getServerKey(), this.getAccountID()) || (LoginServer.getServerKey(this.getAccountID()) == null && !this.getServerKey().isEmpty())) {
            FileoutputUtil.logToFile("logs/Data/客戶端频道KEY异常.txt", "\r\n " + FileoutputUtil.NowTime() + " IP: " + this.client.getSession().remoteAddress().toString().split(":")[0] + " 账号: " + this.client.getAccountName() + " 客戶端key：" + LoginServer.getServerKey(this.getAccountID()) + " 服务端key：" + this.getServerKey() + " 更换频道11");
            Broadcast.broadcastGMMessage(MaplePacketCreator.serverNotice(6, "[GM 密语系统] 非法更换频道 账号 " + this.client.getAccountName()));
            this.client.getSession().close();
            return;
        }
        if (!LoginServer.CanClientKey(this.getClientKey(), this.getAccountID()) || (LoginServer.getClientKey(this.getAccountID()) == null && !this.getClientKey().isEmpty())) {
            FileoutputUtil.logToFile("logs/Data/客戶端进入KEY异常.txt", "\r\n " + FileoutputUtil.NowTime() + " IP: " + this.client.getSession().remoteAddress().toString().split(":")[0] + " 账号: " + this.client.getAccountName() + " 客戶端key：" + LoginServer.getClientKey(this.getAccountID()) + " 服务端key：" + this.getClientKey() + " 更换频道12");
            Broadcast.broadcastGMMessage(MaplePacketCreator.serverNotice(6, "[GM 密语系统] 非法更换频道 账号 " + this.client.getAccountName()));
            this.client.getSession().close();
            return;
        }
        List<String> charNamesa = this.client.loadCharacterNamesByCharId(this.getId());
        for (ChannelServer cs : ChannelServer.getAllInstances()) {
            for (String name : charNamesa) {
                if (cs.getPlayerStorage().getCharacterByName(name) != null) {
                    FileoutputUtil.logToFile("logs/Data/非法登录.txt", "\r\n " + FileoutputUtil.NowTime() + " IP: " + this.client.getSession().remoteAddress().toString().split(":")[0] + " 账号 " + this.client.getAccountName() + "更换频道1");
                    Broadcast.broadcastGMMessage(MaplePacketCreator.serverNotice(6, "[GM 密语系统] 非法更换频道 账号 " + this.client.getAccountName()));
                    this.client.getSession().close();
                    return;
                }
            }
        }
        for (String name2 : charNamesa) {
            if (CashShopServer.getPlayerStorage().getCharacterByName(name2) != null) {
                FileoutputUtil.logToFile("logs/Data/非法登录.txt", "\r\n " + FileoutputUtil.NowTime() + " IP: " + this.client.getSession().remoteAddress().toString().split(":")[0] + " 账号 " + this.client.getAccountName() + "更换频道2");
                Broadcast.broadcastGMMessage(MaplePacketCreator.serverNotice(6, "[GM 密语系统] 非法更换频道 账号 " + this.client.getAccountName()));
                this.client.getSession().close();
                return;
            }
        }
        List<String> charNames = this.client.loadCharacterNamesByCharId(this.getId());
        for (ChannelServer cs2 : ChannelServer.getAllInstances()) {
            for (String name3 : charNames) {
                MapleCharacter character = cs2.getPlayerStorage().getCharacterByName(name3);
                if (character != null) {
                    FileoutputUtil.logToFile("logs/Data/非法登录.txt", "\r\n " + FileoutputUtil.NowTime() + " IP: " + this.client.getSession().remoteAddress().toString().split(":")[0] + " 账号 " + this.client.getAccountName() + "更换频道3");
                    Broadcast.broadcastGMMessage(MaplePacketCreator.serverNotice(6, "[GM 密语系统] 非法更换频道 账号 " + this.client.getAccountName()));
                    this.client.getSession().close();
                    character.getClient().getSession().close();
                }
            }
        }
        for (String name4 : charNames) {
            MapleCharacter charactercs = CashShopServer.getPlayerStorage().getCharacterByName(name4);
            if (charactercs != null) {
                FileoutputUtil.logToFile("logs/Data/非法登录.txt", "\r\n " + FileoutputUtil.NowTime() + " IP: " + this.client.getSession().remoteAddress().toString().split(":")[0] + " 账号 " + this.client.getAccountName() + "更换频道4");
                Broadcast.broadcastGMMessage(MaplePacketCreator.serverNotice(6, "[GM 密语系统] 非法更换频道 账号 " + this.client.getAccountName()));
                this.client.getSession().close();
                charactercs.getClient().getSession().close();
            }
        }
        this.client.setPlayer(null);
        this.client.setReceiving(false);
        this.expirationTask(true, false);
    }

    public void expandInventory(byte type, int amount) {
        MapleInventory inv = this.getInventory(MapleInventoryType.getByType(type));
        inv.addSlot((byte) amount);
        this.client.sendPacket(MaplePacketCreator.getSlotUpdate(type, inv.getSlotLimit()));
    }

    public boolean allowedToTarget(MapleCharacter other) {
        return other != null && (!other.isHidden() || this.getGMLevel() >= other.getGMLevel());
    }

    public int getFollowId() {
        return this.followid;
    }

    public void setFollowId(int fi) {
        this.followid = fi;
        if (fi == 0) {
            this.followinitiator = false;
            this.followon = false;
        }
    }

    public void setFollowInitiator(boolean fi) {
        this.followinitiator = fi;
    }

    public void setFollowOn(boolean fi) {
        this.followon = fi;
    }

    public boolean isFollowOn() {
        return this.followon;
    }

    public boolean isFollowInitiator() {
        return this.followinitiator;
    }

    public void checkFollow() {
        if (this.followon) {
            this.map.broadcastMessage(MaplePacketCreator.followEffect(this.id, 0, null));
            this.map.broadcastMessage(MaplePacketCreator.followEffect(this.followid, 0, null));
            MapleCharacter tt = this.map.getCharacterById(this.followid);
            this.client.sendPacket(MaplePacketCreator.getFollowMessage("Follow canceled."));
            if (tt != null) {
                tt.setFollowId(0);
                tt.getClient().sendPacket(MaplePacketCreator.getFollowMessage("Follow canceled."));
            }
            this.setFollowId(0);
        }
    }

    public int getMarriageId() {
        return this.marriageId;
    }

    public void setMarriageId(int mi) {
        this.marriageId = mi;
    }

    public int getMarriageItemId() {
        return this.marriageItemId;
    }

    public void setMarriageItemId(int mi) {
        this.marriageItemId = mi;
    }

    public boolean isStaff() {
        return this.gmLevel > PlayerGMRank.普通玩家.getLevel();
    }

    public boolean startPartyQuest(int questid) {
        boolean ret = false;
        if (!this.quests.containsKey(MapleQuest.getInstance(questid)) || !this.questinfo.containsKey(Integer.valueOf(questid))) {
            MapleQuestStatus status = this.getQuestNAdd(MapleQuest.getInstance(questid));
            status.setStatus((byte) 1);
            this.updateQuest(status);
            switch (questid) {
                case 1300:
                case 1301:
                case 1302: {
                    this.updateInfoQuest(questid, "min=0;sec=0;date=0000-00-00;have=0;rank=F;try=0;cmp=0;CR=0;VR=0;gvup=0;vic=0;lose=0;draw=0");
                    break;
                }
                case 1204: {
                    this.updateInfoQuest(questid, "min=0;sec=0;date=0000-00-00;have0=0;have1=0;have2=0;have3=0;rank=F;try=0;cmp=0;CR=0;VR=0");
                    break;
                }
                case 1206: {
                    this.updateInfoQuest(questid, "min=0;sec=0;date=0000-00-00;have0=0;have1=0;rank=F;try=0;cmp=0;CR=0;VR=0");
                    break;
                }
                default: {
                    this.updateInfoQuest(questid, "min=0;sec=0;date=0000-00-00;have=0;rank=F;try=0;cmp=0;CR=0;VR=0");
                    break;
                }
            }
            ret = true;
        }
        return ret;
    }

    public String getOneInfo(int questid, String key) {
        if (!this.questinfo.containsKey(Integer.valueOf(questid)) || key == null) {
            return null;
        }
        String[] split3;
        String[] split = split3 = ((String) this.questinfo.get(Integer.valueOf(questid))).split(";");
        for (String x : split3) {
            String[] split2 = x.split("=");
            if (split2.length == 2 && split2[0].equals(key)) {
                return split2[1];
            }
        }
        return null;
    }

    public void updateOneInfo(int questid, String key, String value) {
        if (!this.questinfo.containsKey(Integer.valueOf(questid)) || key == null || value == null) {
            return;
        }
        String[] split = ((String) this.questinfo.get(Integer.valueOf(questid))).split(";");
        boolean changed = false;
        StringBuilder newQuest = new StringBuilder();
        for (String x : split) {
            String[] split2 = x.split("=");
            if (split2.length == 2) {
                if (split2[0].equals(key)) {
                    newQuest.append(key).append("=").append(value);
                } else {
                    newQuest.append(x);
                }
                newQuest.append(";");
                changed = true;
            }
        }
        this.updateInfoQuest(questid, changed ? newQuest.toString().substring(0, newQuest.toString().length() - 1) : newQuest.toString());
    }

    public void recalcPartyQuestRank(int questid) {
        if (!this.startPartyQuest(questid)) {
            String oldRank = this.getOneInfo(questid, "rank");
            if (oldRank == null || oldRank.equals("S")) {
                return;
            }
            String s = oldRank;
            String newRank = null;
            switch (s) {
                case "A": {
                    newRank = "S";
                    break;
                }
                case "B": {
                    newRank = "A";
                    break;
                }
                case "C": {
                    newRank = "B";
                    break;
                }
                case "D": {
                    newRank = "C";
                    break;
                }
                case "F": {
                    newRank = "D";
                    break;
                }
                default: {
                    return;
                }
            }
            List<Pair<String, Pair<String, Integer>>> questInfo = MapleQuest.getInstance(questid).getInfoByRank(newRank);
            for (Pair<String, Pair<String, Integer>> q : questInfo) {
                boolean found = false;
                String val = this.getOneInfo(questid, (String) (q.right).left);
                if (val == null) {
                    return;
                }
                int vall;
                try {
                    vall = Integer.parseInt(val);
                } catch (NumberFormatException e) {
                    return;
                }
                String s2 = (String) q.left;
                switch (s2) {
                    case "less": {
                        found = (vall < ((Integer) (q.right).right).intValue());
                        break;
                    }
                    case "more": {
                        found = (vall > ((Integer) (q.right).right).intValue());
                        break;
                    }
                    case "equal": {
                        found = (vall == ((Integer) (q.right).right).intValue());
                        break;
                    }
                }
                if (!found) {
                    return;
                }
            }
            this.updateOneInfo(questid, "rank", newRank);
        }
    }

    public void tryPartyQuest(int questid) {
        try {
            this.startPartyQuest(questid);
            this.pqStartTime = System.currentTimeMillis();
            this.updateOneInfo(questid, "try", String.valueOf(Integer.parseInt(this.getOneInfo(questid, "try")) + 1));
        } catch (Exception e) {
            FilePrinter.printError("MapleCharacter.txt", (Throwable) e, "tryPartyQuest error");
        }
    }

    public void cmpPartyQuest(int questid, int sl) {
        this.updateOneInfo(questid, "cmp", String.valueOf(Integer.parseInt(this.getOneInfo(questid, "cmp")) - sl));
    }

    public void endPartyQuest(int questid) {
        try {
            this.startPartyQuest(questid);
            if (this.pqStartTime > 0L) {
                long changeTime = System.currentTimeMillis() - this.pqStartTime;
                int mins = (int) (changeTime / 1000L / 60L);
                int secs = (int) (changeTime / 1000L % 60L);
                int mins2 = Integer.parseInt(this.getOneInfo(questid, "min"));
                int secs2 = Integer.parseInt(this.getOneInfo(questid, "sec"));
                if (mins2 <= 0 || mins < mins2) {
                    this.updateOneInfo(questid, "min", String.valueOf(mins));
                    this.updateOneInfo(questid, "sec", String.valueOf(secs));
                    this.updateOneInfo(questid, "date", FilePrinter.getLocalDateString());
                }
                int newCmp = Integer.parseInt(this.getOneInfo(questid, "cmp")) + 1;
                this.updateOneInfo(questid, "cmp", String.valueOf(newCmp));
                this.updateOneInfo(questid, "CR", String.valueOf((int) Math.ceil((double) newCmp * 100.0 / (double) Integer.parseInt(this.getOneInfo(questid, "try")))));
                this.recalcPartyQuestRank(questid);
                this.pqStartTime = 0L;
            }
        } catch (Exception e) {
            FilePrinter.printError("MapleCharacter.txt", (Throwable) e, "endPartyQuest error");
        }
    }

    public void havePartyQuest(int itemId) {
        int index = -1;
        int questid = 0;
        switch (itemId) {
            case 1002798: {
                questid = 1200;
                break;
            }
            case 1072369: {
                questid = 1201;
                break;
            }
            case 1022073: {
                questid = 1202;
                break;
            }
            case 1082232: {
                questid = 1203;
                break;
            }
            case 1002571:
            case 1002572:
            case 1002573:
            case 1002574: {
                questid = 1204;
                index = itemId - 1002571;
                break;
            }
            case 1122010: {
                questid = 1205;
                break;
            }
            case 1032060:
            case 1032061: {
                questid = 1206;
                index = itemId - 1032060;
                break;
            }
            case 3010018: {
                questid = 1300;
                break;
            }
            case 1122007: {
                questid = 1301;
                break;
            }
            case 1122058: {
                questid = 1302;
                break;
            }
            default: {
                return;
            }
        }
        this.startPartyQuest(questid);
        this.updateOneInfo(questid, "have" + ((index == -1) ? "" : Integer.valueOf(index)), "1");
    }

    public void resetStatsByJob(boolean beginnerJob) {
        int baseJob = beginnerJob ? (this.job % 1000) : (this.job % 1000 / 100 * 100);
        if (baseJob == 100) {
            this.resetStats(25, 4, 4, 4);
        } else if (baseJob == 200) {
            this.resetStats(4, 4, 25, 4);
        } else if (baseJob == 300 || baseJob == 400) {
            this.resetStats(4, 25, 4, 4);
        } else if (baseJob == 400) {
            this.resetStats(4, 4, 4, 25);
        } else if (baseJob == 500) {
            this.resetStats(4, 4, 4, 4);
        }
    }

    public void setGMLevel(byte g) {
        this.gmLevel = g;
    }

    public int get刷钱模式() {
        return this.刷钱模式;
    }

    public void set刷钱模式(int invinc) {
        this.刷钱模式 = invinc;
    }

    public boolean hasSummon() {
        return this.hasSummon;
    }

    public void setHasSummon(boolean summ) {
        this.hasSummon = summ;
    }

    public void removeDoor() {
        MapleDoor door = (MapleDoor) this.getDoors().iterator().next();
        for (MapleCharacter chr : door.getTarget().getCharactersThreadsafe()) {
            door.sendDestroyData(chr.getClient());
        }
        for (MapleCharacter chr : door.getTown().getCharactersThreadsafe()) {
            door.sendDestroyData(chr.getClient());
        }
        for (MapleDoor destroyDoor : this.getDoors()) {
            door.getTarget().removeMapObject((MapleMapObject) destroyDoor);
            door.getTown().removeMapObject((MapleMapObject) destroyDoor);
        }
        this.clearDoors();
    }

    public void changeRemoval() {
        this.changeRemoval(false);
    }

    public void changeRemoval(boolean dc) {
        if (this.getTrade() != null) {
            if (this.getTrade().getPartner() != null) {
                MapleTrade local = this.getTrade();
                MapleTrade partners = local.getPartner();
                if (local.isLocked() && partners.isLocked()) {
                    this.client.getSession().write(MaplePacketCreator.enableActions());
                } else {
                    MapleTrade.cancelTrade(this.getTrade(), this.getClient());
                }
            } else {
                MapleTrade.cancelTrade(this.getTrade(), this.client);
            }
        }
        if (this.getCheatTracker() != null) {
            this.getCheatTracker().dispose();
        }
        if (!dc) {
            this.cancelEffectFromBuffStat(MapleBuffStat.MONSTER_RIDING);
            this.cancelEffectFromBuffStat(MapleBuffStat.PUPPET);
        }
        if (this.getPyramidSubway() != null) {
            this.getPyramidSubway().dispose(this);
        }
        if (this.playerShop != null && !dc) {
            this.playerShop.removeVisitor(this);
            if (this.playerShop.isOwner(this)) {
                this.playerShop.setOpen(true);
            }
        }
        if (!this.getDoors().isEmpty()) {
            this.removeDoor();
        }
        this.disposeClones();
        NPCScriptManager.getInstance().dispose(this.client);
    }

    public void updateTick(int newTick) {
        if (this.anticheat != null) {
            this.anticheat.updateTick(newTick);
        }
    }

    public boolean canUseFamilyBuff(MapleFamilyBuffEntry buff) {
        MapleQuestStatus stat = this.getQuestNAdd(MapleQuest.getInstance(buff.questID));
        if (stat.getCustomData() == null) {
            stat.setCustomData("0");
        }
        return Long.parseLong(stat.getCustomData()) + 86400000L < System.currentTimeMillis();
    }

    public void useFamilyBuff(MapleFamilyBuffEntry buff) {
        MapleQuestStatus stat = this.getQuestNAdd(MapleQuest.getInstance(buff.questID));
        stat.setCustomData(String.valueOf(System.currentTimeMillis()));
    }

    public List<Pair<Integer, Integer>> usedBuffs() {
        List<Pair<Integer, Integer>> used = (List<Pair<Integer, Integer>>) new ArrayList();
        for (MapleFamilyBuffEntry buff : MapleFamilyBuff.getBuffEntry()) {
            if (!this.canUseFamilyBuff(buff)) {
                used.add(new Pair(Integer.valueOf(buff.index), Integer.valueOf(buff.count)));
            }
        }
        return used;
    }

    public String getTeleportName() {
        return this.teleportname;
    }

    public void setTeleportName(String tname) {
        this.teleportname = tname;
    }

    public int getNoJuniors() {
        if (this.mfc == null) {
            return 0;
        }
        return this.mfc.getNoJuniors();
    }

    public MapleFamilyCharacter getMFC() {
        return this.mfc;
    }

    public void makeMFC(int familyid, int seniorid, int junior1, int junior2) {
        if (familyid > 0) {
            MapleFamily f = Family.getFamily(familyid);
            if (f == null) {
                this.mfc = null;
            } else {
                this.mfc = f.getMFC(this.id);
                if (this.mfc == null) {
                    this.mfc = f.addFamilyMemberInfo(this, seniorid, junior1, junior2);
                }
                if (this.mfc.getSeniorId() != seniorid) {
                    this.mfc.setSeniorId(seniorid);
                }
                if (this.mfc.getJunior1() != junior1) {
                    this.mfc.setJunior1(junior1);
                }
                if (this.mfc.getJunior2() != junior2) {
                    this.mfc.setJunior2(junior2);
                }
            }
        } else {
            this.mfc = null;
        }
    }

    public void setFamily(int newf, int news, int newj1, int newj2) {
        if (this.mfc == null || newf != this.mfc.getFamilyId() || news != this.mfc.getSeniorId() || newj1 != this.mfc.getJunior1() || newj2 != this.mfc.getJunior2()) {
            this.makeMFC(newf, news, newj1, newj2);
        }
    }

    public int maxBattleshipHP(int skillid) {
        return this.getSkillLevel(skillid) * 5000 + (this.getLevel() - 120) * 3000;
    }

    public int currentBattleshipHP() {
        return this.battleshipHP;
    }

    public int getGachExp() {
        return this.gachexp;
    }

    public void setGachExp(int ge) {
        this.gachexp = ge;
    }

    public void sendEnglishQuiz(String msg) {
        this.client.sendPacket(MaplePacketCreator.englishQuizMsg(msg));
    }

    public void fakeRelog() {
        int chan = this.client.getChannel();
        this.client.sendPacket(MaplePacketCreator.getCharInfo(this));
        MapleMap mapp = this.getMap();
        mapp.removePlayer(this);
        mapp.addPlayer(this);
        this.ForcechangeChannel(chan);
    }

    public String getcharmessage() {
        return this.charmessage;
    }

    public void setcharmessage(String s) {
        if (s.getBytes().length >= 24) {
            s = s.substring(0, 24);
        }
        this.charmessage = s;
    }

    public int getexpression() {
        return this.expression;
    }

    public void setexpression(int s) {
        this.expression = s;
    }

    public int getconstellation() {
        return this.constellation;
    }

    public void setconstellation(int s) {
        this.constellation = s;
    }

    public int getblood() {
        return this.blood;
    }

    public void setblood(int s) {
        this.blood = s;
    }

    public int getmonth() {
        return this.month;
    }

    public void setmonth(int s) {
        this.month = s;
    }

    public int getday() {
        return this.day;
    }

    public void setday(int s) {
        this.day = s;
    }

    public int getTeam() {
        return this.coconutteam;
    }

    public int getBeans() {
        return this.beans;
    }

    public void gainBeans(int s) {
        this.beans += s;
    }

    public void setBeans(int s) {
        this.beans = s;
    }

    public int getBeansNum() {
        return this.beansNum;
    }

    public void setBeansNum(int beansNum) {
        this.beansNum = beansNum;
    }

    public int getBeansRange() {
        return this.beansRange;
    }

    public void setBeansRange(int beansRange) {
        this.beansRange = beansRange;
    }

    public boolean isCanSetBeansNum() {
        return this.canSetBeansNum;
    }

    public void setCanSetBeansNum(boolean canSetBeansNum) {
        this.canSetBeansNum = canSetBeansNum;
    }

    public boolean getBeansStart() {
        return this.beansStart;
    }

    public void setBeansStart(boolean beansStart) {
        this.beansStart = beansStart;
    }

    public boolean haveGM() {
        return this.gmLevel >= 2 && this.gmLevel <= 3;
    }

    public void setprefix(String prefix) {
        this.prefix = prefix;
    }

    public String getPrefix() {
        return this.prefix;
    }

    public void gainItem(int code, int amount) {
        MapleInventoryManipulator.addById(this.client, code, (short) amount, null);
    }

    public void gainItem(int code) {
        MapleInventoryManipulator.addById(this.client, code, (short) 1, null);
    }

    public void giftMedal(int id) {
        if (!this.getInventory(MapleInventoryType.EQUIP).isFull() && this.getInventory(MapleInventoryType.EQUIP).countById(id) == 0 && this.getInventory(MapleInventoryType.EQUIPPED).countById(id) == 0) {
            MapleInventoryManipulator.addById(this.client, id, (short) 1);
            Broadcast.broadcastMessage(MaplePacketCreator.serverNotice(6, "[恭喜]" + this.getName() + "刚才得到了 " + MapleItemInformationProvider.getInstance().getName(id) + "！"));
        } else if (this.getInventory(MapleInventoryType.EQUIP).countById(id) == 0 && this.getInventory(MapleInventoryType.EQUIPPED).countById(id) == 0) {
            MapleInventoryManipulator.drop(this.client, MapleInventoryType.EQUIP, (short) 1, (short) 1);
            MapleInventoryManipulator.addById(this.client, id, (short) 1);
            Broadcast.broadcastMessage(MaplePacketCreator.serverNotice(6, "[恭喜]" + this.getName() + "刚才得到了 " + MapleItemInformationProvider.getInstance().getName(id) + "！"));
        }
    }

    public void showInstruction(String msg, int width, int height) {
        this.client.getSession().writeAndFlush(MaplePacketCreator.sendHint(msg, width, height));
    }

    public void removeItem(int id, int quantity) {
        MapleInventoryManipulator.removeById(this.client, GameConstants.getInventoryType(id), id, -quantity, true, false);
        this.client.sendPacket(MaplePacketCreator.getShowItemGain(id, (short) quantity, true));
    }

    public String getVipName() {
        String name = "";
        if (this.getVip() > 0) {
            name = ServerConfig.getVipMedalName(this.getVip());
        }
        return name;
    }

    public String getNick() {
        String name = "";
        if (this.getOneTimeLog("关闭VIP星星数显示") < 1 && this.getVipMedal() && this.getVip() > 0) {
            name += this.getVipName();
        }
        if (this.getGMLevel() > 0) {
            name += "";
        }
        return name;
    }

    public boolean getVipMedal() {
        return this.Vip_Medal;
    }

    public void setVipMedat(boolean x) {
        this.Vip_Medal = x;
    }

    public void setVipMedal(boolean x) {
        this.Vip_Medal = x;
    }

    public int getVipExpRate() {
        if (this.getVip() <= 5) {
            return (this.getVip() == 0) ? 0 : ((this.getVip() + 1) * 5);
        }
        return (this.getVip() == 0) ? 0 : ((this.getVip() + 1) * 5);
    }

    public void control_精灵商人(boolean control) {
        this.精灵商人购买开关 = control;
    }

    public void control_玩家私聊(boolean control) {
        this.玩家私聊开关 = control;
    }

    public void control_玩家密语(boolean control) {
        this.玩家密语开关 = control;
    }

    public void control_好友聊天(boolean control) {
        this.好友聊天开关 = control;
    }

    public void control_队伍聊天(boolean control) {
        this.队伍聊天开关 = control;
    }

    public void control_公会聊天(boolean control) {
        this.公会聊天开关 = control;
    }

    public void control_联盟聊天(boolean control) {
        this.联盟聊天开关 = control;
    }

    public void control_吸怪讯息(boolean control) {
        this.GM吸怪讯息开关 = control;
    }

    public boolean get_control_精灵商人() {
        return this.精灵商人购买开关;
    }

    public boolean get_control_玩家私聊() {
        return this.玩家私聊开关;
    }

    public boolean get_control_玩家密语() {
        return this.玩家密语开关;
    }

    public boolean get_control_好友聊天() {
        return this.好友聊天开关;
    }

    public boolean get_control_队伍聊天() {
        return this.队伍聊天开关;
    }

    public boolean get_control_公会聊天() {
        return this.公会聊天开关;
    }

    public boolean get_control_联盟聊天() {
        return this.联盟聊天开关;
    }

    public boolean get_control_吸怪讯息() {
        return this.GM吸怪讯息开关;
    }

    public int getDiseaseSize() {
        return this.diseases.size();
    }

    public int getMSG() {
        return this.MSG;
    }

    public void setMSG(int x) {
        this.MSG = x;
    }

    public void addMSG() {
        ++this.MSG;
    }

    public void fly() {
    }

    public boolean CanStorage() {
        if (this.lastStorageTime + 1000L > System.currentTimeMillis()) {
            return false;
        }
        this.lastStorageTime = System.currentTimeMillis();
        return true;
    }

    public boolean canHP() {
        if (this.lastHPTime + 5000L > System.currentTimeMillis()) {
            return false;
        }
        this.lastHPTime = System.currentTimeMillis();
        return true;
    }

    public boolean canMP() {
        if (this.lastMPTime + 5000L > System.currentTimeMillis()) {
            return false;
        }
        this.lastMPTime = System.currentTimeMillis();
        return true;
    }

    public boolean canUseMD() {
        if (this.lastMDTime + 5000L > System.currentTimeMillis()) {
            return false;
        }
        this.lastMDTime = System.currentTimeMillis();
        return true;
    }

    public void add打怪() {
        ++this.打怪;
    }

    public int get打怪() {
        return this.打怪;
    }

    public void add吸怪() {
        ++this.吸怪;
    }

    public int get吸怪() {
        return this.吸怪;
    }

    public void addFly_吸怪() {
        ++this.FLY_吸怪;
    }

    public int getFly_吸怪() {
        return this.FLY_吸怪;
    }

    public int Aran_ReduceCombo(int skill) {
        int reduce = 0;
        switch (skill) {
            case 21100004:
            case 21100005: {
                reduce = 30;
                break;
            }
            case 21110004: {
                reduce = 100;
                break;
            }
            case 21120006:
            case 21120007: {
                reduce = 200;
                break;
            }
        }
        return reduce;
    }

    public int getAcash() {
        return this.getAcash(this);
    }

    public int getAcash(MapleCharacter chr) {
        int maxtimes = 10;
        int nowtime = 0;
        int delay = 500;
        boolean error = false;
        int x = 0;
        do {
            ++nowtime;
            try (Connection con = BeePool.getConnection()) {
                Statement stmt = con.createStatement();
                ResultSet rs = stmt.executeQuery("Select Acash from Accounts Where id = " + chr.getClient().getAccID());
                while (rs.next()) {
                    int debug = -1;
                    try {
                        debug = rs.getInt("Acash");
                    } catch (Exception ex2) {
                    }
                    if (debug != -1) {
                        x = rs.getInt("Acash");
                        error = false;
                    } else {
                        error = true;
                    }
                }
                rs.close();
            } catch (SQLException SQL) {
                System.err.println("[getAcash]无法连接资料库");
                FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) SQL);
            } catch (Exception ex) {
                FilePrinter.printError("MapleCharacter.txt", (Throwable) ex, "getAcash");
                System.err.println("[getAcash]" + ex);
                FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) ex);
            }
            if (error) {
                try {
                    Thread.sleep((long) delay);
                } catch (Exception ex) {
                    FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) ex);
                }
            }
        } while (error && nowtime < maxtimes);
        return x;
    }

    public void setAcash(int x) {
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = con.prepareStatement("Update Accounts set Acash = ? Where id = ?");
            ps.setInt(1, x);
            ps.setInt(2, this.getClient().getAccID());
            ps.execute();
            ps.close();
        } catch (SQLException ex) {
            System.err.println("[Acash]无法连接资料库");
            FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) ex);
        } catch (Exception ex2) {
            FilePrinter.printError("MapleCharacter.txt", (Throwable) ex2, "SetAcash");
            System.err.println("[setAcash]" + ex2);
            FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) ex2);
        }
    }

    public int getCZJF() {
        return this.getCZJF(this);
    }

    public int getCZJF(MapleCharacter chr) {
        int maxtimes = 10;
        int nowtime = 0;
        int delay = 500;
        boolean error = false;
        int x = 0;
        do {
            ++nowtime;
            try (Connection con = BeePool.getConnection()) {
                Statement stmt = con.createStatement();
                ResultSet rs = stmt.executeQuery("Select CZJF from Accounts Where id = " + chr.getClient().getAccID());
                while (rs.next()) {
                    int debug = -1;
                    try {
                        debug = rs.getInt("CZJF");
                    } catch (Exception ex2) {
                    }
                    if (debug != -1) {
                        x = rs.getInt("CZJF");
                        error = false;
                    } else {
                        error = true;
                    }
                }
                rs.close();
            } catch (SQLException SQL) {
                System.err.println("[getCZJF]无法连接资料库");
                FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) SQL);
            } catch (Exception ex) {
                FilePrinter.printError("MapleCharacter.txt", (Throwable) ex, "getCZJF");
                System.err.println("[getCZJF]" + ex);
                FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) ex);
            }
            if (error) {
                try {
                    Thread.sleep((long) delay);
                } catch (Exception ex) {
                    FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) ex);
                }
            }
        } while (error && nowtime < maxtimes);
        return x;
    }

    public void setCZJF(int x) {
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = con.prepareStatement("Update Accounts set CZJF = ? Where id = ?");
            ps.setInt(1, x);
            ps.setInt(2, this.getClient().getAccID());
            ps.execute();
            ps.close();
        } catch (SQLException ex) {
            System.err.println("[CZJF]无法连接资料库");
            FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) ex);
        } catch (Exception ex2) {
            FilePrinter.printError("MapleCharacter.txt", (Throwable) ex2, "SetCZJF");
            System.err.println("[setCZJF]" + ex2);
            FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) ex2);
        }
    }

    public int getTGJF() {
        return this.getTGJF(this);
    }

    public int getTGJF(MapleCharacter chr) {
        int maxtimes = 10;
        int nowtime = 0;
        int delay = 500;
        boolean error = false;
        int x = 0;
        do {
            ++nowtime;
            try (Connection con = BeePool.getConnection()) {
                Statement stmt = con.createStatement();
                ResultSet rs = stmt.executeQuery("Select TGJF from Accounts Where id = " + chr.getClient().getAccID());
                while (rs.next()) {
                    int debug = -1;
                    try {
                        debug = rs.getInt("TGJF");
                    } catch (Exception ex2) {
                    }
                    if (debug != -1) {
                        x = rs.getInt("TGJF");
                        error = false;
                    } else {
                        error = true;
                    }
                }
                rs.close();
            } catch (SQLException SQL) {
                System.err.println("[getTGJF]无法连接资料库");
                FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) SQL);
            } catch (Exception ex) {
                FilePrinter.printError("MapleCharacter.txt", (Throwable) ex, "getTGJF");
                System.err.println("[getTGJF]" + ex);
                FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) ex);
            }
            if (error) {
                try {
                    Thread.sleep((long) delay);
                } catch (Exception ex) {
                    FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) ex);
                }
            }
        } while (error && nowtime < maxtimes);
        return x;
    }

    public void setTGJF(int x) {
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = con.prepareStatement("Update Accounts set TGJF = ? Where id = ?");
            ps.setInt(1, x);
            ps.setInt(2, this.getClient().getAccID());
            ps.execute();
            ps.close();
        } catch (SQLException ex) {
            System.err.println("[TGJF]无法连接资料库");
            FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) ex);
        } catch (Exception ex2) {
            FilePrinter.printError("MapleCharacter.txt", (Throwable) ex2, "SetTGJFF");
            System.err.println("[setTGJF]" + ex2);
            FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) ex2);
        }
    }

    public int getTJJF() {
        return this.getTJJF(this);
    }

    public int getTJJF(MapleCharacter chr) {
        int maxtimes = 10;
        int nowtime = 0;
        int delay = 500;
        boolean error = false;
        int x = 0;
        do {
            ++nowtime;
            try (Connection con = BeePool.getConnection()) {
                Statement stmt = con.createStatement();
                ResultSet rs = stmt.executeQuery("Select TJJF from Accounts Where id = " + chr.getClient().getAccID());
                while (rs.next()) {
                    int debug = -1;
                    try {
                        debug = rs.getInt("TJJF");
                    } catch (Exception ex2) {
                    }
                    if (debug != -1) {
                        x = rs.getInt("TJJF");
                        error = false;
                    } else {
                        error = true;
                    }
                }
                rs.close();
            } catch (SQLException SQL) {
                System.err.println("[getTJJF]无法连接资料库");
                FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) SQL);
            } catch (Exception ex) {
                FilePrinter.printError("MapleCharacter.txt", (Throwable) ex, "getTJJF");
                System.err.println("[getTJJF]" + ex);
                FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) ex);
            }
            if (error) {
                try {
                    Thread.sleep((long) delay);
                } catch (Exception ex) {
                    FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) ex);
                }
            }
        } while (error && nowtime < maxtimes);
        return x;
    }

    public void setTJJF(int x) {
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = con.prepareStatement("Update Accounts set TJJF = ? Where id = ?");
            ps.setInt(1, x);
            ps.setInt(2, this.getClient().getAccID());
            ps.execute();
            ps.close();
        } catch (SQLException ex) {
            System.err.println("[TJJF]无法连接资料库");
            FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) ex);
        } catch (Exception ex2) {
            FilePrinter.printError("MapleCharacter.txt", (Throwable) ex2, "SetTJJFF");
            System.err.println("[setTJJF]" + ex2);
            FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) ex2);
        }
    }

    public void modifyJF(int type, int quantity) {
        switch (type) {
            case 1: {
                int CZJF = this.getCZJF();
                if (CZJF + quantity < 0) {
                    return;
                }
                this.setCZJF(CZJF + quantity);
                break;
            }
            case 2: {
                int TGJF = this.getTGJF();
                if (TGJF + quantity < 0) {
                    return;
                }
                this.setTGJF(TGJF + quantity);
                break;
            }
            case 3: {
                int TJJF = this.getTJJF();
                if (TJJF + quantity < 0) {
                    return;
                }
                this.setTJJF(TJJF + quantity);
                break;
            }
            case 4: {
                int DDJF = this.getDDJF();
                if (DDJF + quantity < 0) {
                    return;
                }
                this.setDDJF(DDJF + quantity);
                break;
            }
        }
    }

    public boolean getAuto吸怪() {
        return this.auto吸怪;
    }

    public void setAuto吸怪(boolean x) {
        this.auto吸怪 = x;
    }

    public void warpAuto吸怪(MapleCharacter chr_) {
        MapleCharacter chr = this;
        try {
            if (chr.getMapId() != chr_.getMapId()) {
                chr.changeMap(chr_.getMapId());
                chr.changeMap(chr_.getMap(), chr_.getMap().findClosestSpawnpoint(chr_.getPosition()));
            }
            if (chr.getClient().getChannel() != chr_.getClient().getChannel()) {
                chr.changeChannel(chr_.getClient().getChannel());
            }
        } catch (Exception ex) {
        }
    }

    public void setDebugMessage(boolean control) {
        this.DebugMessage = control;
    }

    public boolean getDebugMessage() {
        return this.DebugMessage;
    }

    public void RemoveHired() {
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = con.prepareStatement("Delete From hiredmerch Where characterid = ?");
            ps.setInt(1, this.id);
            ps.execute();
            ps = con.prepareStatement("Delete From hiredmerchitems Where characterid = ?");
            ps.setInt(1, this.id);
            ps.execute();
            ps.close();
        } catch (Exception ex) {
            FilePrinter.printError("MapleCharacter.txt", (Throwable) ex, "RemoveHired");
            FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) ex);
        }
    }

    public void maxSkills() {
        for (ISkill skil : SkillFactory.getAllSkills()) {
            this.changeSkillLevel(skil, skil.getMaxLevel(), skil.getMaxLevel());
        }
    }

    public void maxSkillsa() {
        for (ISkill skil : SkillFactory.getAllSkills()) {
            if (skil.getId() != 5121003 && skil.getId() != 5111005 && skil.getId() != 15111002) {
                this.changeSkillLevel(skil, skil.getMaxLevel(), skil.getMaxLevel());
            }
        }
    }

    public void clearSkills() {
        for (ISkill skil : SkillFactory.getAllSkills()) {
            this.changeSkillLevel(skil, (byte) 0, (byte) 0);
        }
    }

    public void LearnSameSkill(MapleCharacter victim) {
        for (ISkill skil : SkillFactory.getAllSkills()) {
            if (victim.getSkillLevel(skil) > 0) {
                this.changeSkillLevel(skil, victim.getSkillLevel(skil), victim.getMasterLevel(skil));
            }
        }
    }

    public void openSkill(MapleCharacter victim) {
        for (ISkill skil : SkillFactory.getAllSkills()) {
            if (victim.getSkillLevel(skil) < 1) {
                this.changeSkillLevel(skil, (byte) 0, (byte) 10);
            }
        }
    }

    public int getStr() {
        return this.getStat().getStr();
    }

    public int getInt() {
        return this.getStat().getInt();
    }

    public int getLuk() {
        return this.getStat().getLuk();
    }

    public int getDex() {
        return this.getStat().getDex();
    }

    public int getHp() {
        return this.getStat().getHp();
    }

    public int getMp() {
        return this.getStat().getMp();
    }

    public int getMaxHp() {
        return this.getStat().getMaxHp();
    }

    public int getMaxMp() {
        return this.getStat().getMaxMp();
    }

    public void setHp(int amount) {
        this.getStat().setHp(amount);
    }

    public void setMp(int amount) {
        this.getStat().setMp(amount);
    }

    public void setMaxHp(int amount) {
        this.getStat().setMaxHp((short) amount);
    }

    public void setMaxMp(int amount) {
        this.getStat().setMaxMp((short) amount);
    }

    public void setStr(int str) {
        this.stats.str = (short) str;
        this.stats.recalcLocalStats(false);
    }

    public void setLuk(int luk) {
        this.stats.luk = (short) luk;
        this.stats.recalcLocalStats(false);
    }

    public void setDex(int dex) {
        this.stats.dex = (short) dex;
        this.stats.recalcLocalStats(false);
    }

    public void setInt(int int_) {
        this.stats.int_ = (short) int_;
        this.stats.recalcLocalStats(false);
    }

    public void setMeso(int mesos) {
        this.meso = mesos;
    }

    public void updateFame() {
        this.updateSingleStat(MapleStat.FAME, (int) this.getFame());
    }

    public boolean inBossMap() {
        return MapConstants.inBossMap(this.getMapId());
    }

    public static boolean isVpn(String ip) {
        switch (ip) {
            case "/1.34.145.220":
            case "/59.125.5.52":
            case "/59.126.97.123":
            case "/60.251.73.100":
            case "/61.219.216.173":
            case "/61.219.216.174":
            case "/61.227.252.169":
            case "/61.228.228.128": {
                return true;
            }
            default: {
                return false;
            }
        }
    }

    public boolean isKOC() {
        return this.job >= 1000 && this.job < 2000;
    }

    public boolean isAran() {
        return this.job >= 2000 && this.job <= 2112 && this.job != 2001;
    }

    public boolean isAdventurer() {
        return this.job >= 0 && this.job < 1000;
    }

    public boolean isCygnus() {
        return this.job >= 1000 && this.job <= 1512;
    }

    public boolean isGod() {
        return this.gmLevel >= 100;
    }

    public static String getCharacterNameById(int id) {
        String name = null;
        MapleCharacter chr = getOnlineCharacterById(id);
        if (chr != null) {
            return chr.getName();
        }
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = null;
            Statement stmt = con.createStatement();
            ps = con.prepareStatement("select name from characters where id = ?");
            ps.setInt(1, id);
            ResultSet rs = ps.executeQuery();
            while (rs.next()) {
                name = rs.getString("name");
            }
            ps.close();
            rs.close();
        } catch (Exception ex) {
            FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) ex);
        }
        return name;
    }

    public static String getCharacterNameById2(int id) {
        String name = null;
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = null;
            Statement stmt = con.createStatement();
            ps = con.prepareStatement("select name from characters where id = ?");
            ps.setInt(1, id);
            ResultSet rs = ps.executeQuery();
            while (rs.next()) {
                name = rs.getString("name");
            }
            ps.close();
            rs.close();
        } catch (Exception ex) {
            FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) ex);
        }
        return name;
    }

    public static int getCharacterIdByName(String name) {
        int id = -1;
        MapleCharacter chr = getOnlineCharacterByName(name);
        if (chr != null) {
            return chr.getId();
        }
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = null;
            Statement stmt = con.createStatement();
            ps = con.prepareStatement("select id from characters where name = ?");
            ps.setString(1, name);
            ResultSet rs = ps.executeQuery();
            while (rs.next()) {
                id = rs.getInt("id");
            }
            ps.close();
            rs.close();
        } catch (Exception ex) {
            FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) ex);
        }
        return id;
    }

    public static MapleCharacter getOnlineCharacterById(int cid) {
        MapleCharacter chr = null;
        if (Find.findChannel(cid) >= 1) {
            chr = ChannelServer.getInstance(Find.findChannel(cid)).getPlayerStorage().getCharacterById(cid);
            if (chr != null) {
                return chr;
            }
        }
        return null;
    }

    public static MapleCharacter getOnlineCharacterByName(String name) {
        MapleCharacter chr = null;
        if (Find.findChannel(name) >= 1) {
            chr = ChannelServer.getInstance(Find.findChannel(name)).getPlayerStorage().getCharacterByName(name);
            if (chr != null) {
                return chr;
            }
        }
        return null;
    }

    public static MapleCharacter getCharacterById(int cid) {
        MapleCharacter chr = getOnlineCharacterById(cid);
        if (chr != null) {
            return chr;
        }
        String name = getCharacterNameById(cid);
        return (name == null) ? null : loadCharFromDB(cid, new MapleClient(null, null, (Channel) new MockIOSession()), true);
    }

    public static MapleCharacter getCharacterByName(String name) {
        MapleCharacter chr = getOnlineCharacterByName(name);
        if (chr != null) {
            return chr;
        }
        int cid = getCharacterIdByName(name);
        return (cid == -1) ? null : loadCharFromDB(cid, new MapleClient(null, null, (Channel) new MockIOSession()), true);
    }

    public static void setMP(Map<MapleCharacter, Integer> GiveList, boolean showMessage) {
        Iterator<MapleCharacter> iter = GiveList.keySet().iterator();
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = null;
            while (iter.hasNext()) {
                StringBuilder sql = new StringBuilder();
                MapleCharacter chr = (MapleCharacter) iter.next();
                int MP = ((Integer) GiveList.get(chr)).intValue();
                sql.append("Update Accounts set MP = ");
                sql.append(chr.getMP() + MP);
                sql.append(" Where id = ");
                sql.append(chr.getAccountID());
                ps = con.prepareStatement(sql.toString());
                ps.execute();
                if (showMessage) {
                    String MSG = "「在线奖励」获得在线点数 " + MP + " 若要领取请输入 @在线点数/@jcds";
                    chr.dropMessage(MSG);
                }
            }
            if (ps != null) {
                ps.close();
            }
        } catch (SQLException ex) {
            System.err.println("[setMP]无法连接资料库 " + ex);
            FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) ex);
        } catch (Exception ex2) {
            FilePrinter.printError("MapleCharacter.txt", (Throwable) ex2, "setMP");
            System.err.println("[setMP]" + ex2);
            FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) ex2);
        }
    }

    public void setMP(int x) {
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = con.prepareStatement("Update Accounts set MP = ? Where id = ?");
            ps.setInt(1, x);
            ps.setInt(2, this.getClient().getAccID());
            ps.execute();
            ps.close();
        } catch (SQLException ex) {
            System.err.println("[setMP]无法连接资料库 " + ex);
            FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) ex);
        } catch (Exception ex2) {
            FilePrinter.printError("MapleCharacter.txt", (Throwable) ex2, "setMP");
            System.err.println("[setMP]" + ex2);
            FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) ex2);
        }
    }

    public int getMP() {
        int maxtimes = 10;
        int nowtime = 0;
        int delay = 500;
        boolean error = false;
        int mp = 0;
        do {
            ++nowtime;
            try (Connection con = BeePool.getConnection()) {
                Statement stmt = con.createStatement();
                ResultSet rs = stmt.executeQuery("Select MP from Accounts Where id = " + this.getClient().getAccID());
                while (rs.next()) {
                    int debug = -1;
                    try {
                        debug = rs.getInt("MP");
                    } catch (Exception ex2) {
                    }
                    if (debug != -1) {
                        mp = rs.getInt("MP");
                        error = false;
                    } else {
                        error = true;
                    }
                }
                rs.close();
            } catch (SQLException SQL) {
                System.err.println("[getMP] 无法连接资料库" + SQL);
                FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) SQL);
            } catch (Exception ex) {
                FilePrinter.printError("MapleCharacter.txt", (Throwable) ex, "getMP");
                FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) ex);
            }
            if (error) {
                try {
                    Thread.sleep((long) delay);
                } catch (Exception ex) {
                    FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) ex);
                }
            }
        } while (error && nowtime < maxtimes);
        return mp;
    }

    public boolean hasBlockedInventory(boolean dead) {
        boolean has = false;
        if (dead) {
            has = (!this.isAlive() || this.getTrade() != null || this.getConversation() > 0 || this.getPlayerShop() != null);
        } else {
            has = (this.getTrade() != null || this.getConversation() > 0 || this.getPlayerShop() != null);
        }
        return has;
    }

    public boolean hasBlockedInventory2(boolean dead) {
        boolean has = false;
        if (dead) {
            has = (!this.isAlive() || this.getTrade() != null || this.getPlayerShop() != null);
        } else {
            has = (this.getTrade() != null || this.getPlayerShop() != null);
        }
        return has;
    }

    public String getNowMacs() {
        return this.nowmacs;
    }

    public void setNowMacs(String macs) {
        this.nowmacs = macs;
    }

    public int loadVip(int accountID) {
        int vip = 0;
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = con.prepareStatement("SELECT vip FROM accounts WHERE id = ?");
            ps.setInt(1, accountID);
            ResultSet rs = ps.executeQuery();
            if (rs.next()) {
                vip = rs.getShort("vip");
                ps.close();
                rs.close();
            }
        } catch (SQLException e) {
            FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) e);
        }
        return vip;
    }

    public Map<Integer, MapleBuffStatValueHolder> getSkillID() {
        return this.skillID;
    }

    public boolean isItemBuffedValue(int itemid) {
        LinkedList<MapleBuffStatValueHolder> allBuffs = new LinkedList(this.skillID.values());
        for (MapleBuffStatValueHolder mbsvh : allBuffs) {
            if (mbsvh.effect.getSourceId() == itemid) {
                return true;
            }
        }
        return false;
    }

    public void startMapEffect(String msg, int itemId) {
        this.startMapEffect(msg, itemId, 10000);
    }

    public void startMapEffect(String msg, int itemId, int duration) {
        MapleMapEffect mapEffect = new MapleMapEffect(msg, itemId);
        this.getClient().getSession().writeAndFlush(mapEffect.makeStartData());
        EventTimer.getInstance().schedule((Runnable) new Runnable() {
            @Override
            public void run() {
                MapleCharacter.this.getClient().getSession().writeAndFlush(mapEffect.makeDestroyData());
            }
        }, (long) duration);
    }

    public void forceCompleteQuest(int id) {
        MapleQuest.getInstance(id).forceComplete(this, 0);
    }

    public String getLoginKey() {
        return this.loginkey;
    }

    public String getServerKey() {
        return this.serverkey;
    }

    public String getClientKey() {
        return this.clientkey;
    }

    public boolean chrdangerousIp(String lip) {
        String ip = lip.substring(1, lip.lastIndexOf(58));
        boolean ret = false;
        try (Connection con = BeePool.getConnection();
             PreparedStatement ps = con.prepareStatement("SELECT COUNT(*) FROM dangerousip WHERE ? LIKE CONCAT(ip, '%')")) {
            ps.setString(1, ip);
            try (ResultSet rs = ps.executeQuery()) {
                rs.next();
                if (rs.getInt(1) > 0) {
                    ret = true;
                }
            }
        } catch (SQLException ex) {
            System.err.println("Error dangerousIp " + ex);
            FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) ex);
        }
        return ret;
    }

    public void setChrDangerousIp(String lip) {
        String ip = lip.substring(1, lip.lastIndexOf(58));
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = con.prepareStatement("INSERT INTO dangerousip (ip) VALUES (?)");
            ps.setString(1, ip);
            ps.executeUpdate();
            ps.close();
        } catch (SQLException Wx) {
            FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) Wx);
        }
    }

    public void updateNewState(int newstate, int accountId) {
        try (Connection con = BeePool.getConnection();
             PreparedStatement ps = con.prepareStatement("UPDATE `accounts` SET `loggedin` = ? WHERE id = ?")) {
            ps.setInt(1, newstate);
            ps.setInt(2, accountId);
            ps.executeUpdate();
        } catch (SQLException ex) {
            FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) ex);
        }
    }

    public int getIntNoRecord(int questID) {
        MapleQuestStatus stat = this.getQuestNoAdd(MapleQuest.getInstance(questID));
        if (stat == null || stat.getCustomData() == null) {
            return 0;
        }
        return Integer.parseInt(stat.getCustomData());
    }

    public int getIntRecord(int questID) {
        MapleQuestStatus stat = this.getQuestNAdd(MapleQuest.getInstance(questID));
        if (stat.getCustomData() == null) {
            stat.setCustomData("0");
        }
        return Integer.parseInt(stat.getCustomData());
    }

    public void updatePetAuto() {
        if (this.getIntNoRecord(122221) > 0) {
            this.client.getSession().writeAndFlush(MaplePacketCreator.petAutoHP(this.getIntRecord(122221)));
        }
        if (this.getIntNoRecord(122223) > 0) {
            this.client.getSession().writeAndFlush(MaplePacketCreator.petAutoMP(this.getIntRecord(122223)));
        }
    }

    public long getChrMeso() {
        long meso = 0L;
        try (Connection con = BeePool.getConnection();
             PreparedStatement ps = con.prepareStatement("SELECT * FROM characters")) {
            ResultSet rs = ps.executeQuery();
            while (rs.next()) {
                meso += (long) rs.getInt("meso");
            }
            rs.close();
        } catch (Exception e) {
            FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) e);
            e.printStackTrace();
        }
        return meso;
    }

    public long getStorageMeso() {
        long meso = 0L;
        try (Connection con = BeePool.getConnection();
             PreparedStatement ps = con.prepareStatement("SELECT * FROM storages")) {
            ResultSet rs = ps.executeQuery();
            while (rs.next()) {
                meso += (long) rs.getInt("meso");
            }
            rs.close();
        } catch (Exception e) {
            FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) e);
            e.printStackTrace();
        }
        return meso;
    }

    public long getHiredMerchMeso() {
        long meso = 0L;
        try (Connection con = BeePool.getConnection();
             PreparedStatement ps = con.prepareStatement("SELECT * FROM hiredmerch")) {
            ResultSet rs = ps.executeQuery();
            while (rs.next()) {
                meso += (long) rs.getInt("Mesos");
            }
            rs.close();
        } catch (Exception e) {
            FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) e);
            e.printStackTrace();
        }
        return meso;
    }

    public int getQianDaoTime(String bossid) {
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = con.prepareStatement("select count(*) from bosslog where characterid = ? and bossid = ? and lastattempt >= DATE_SUB(curdate(),INTERVAL 0 DAY)");
            ps.setInt(1, this.id);
            ps.setString(2, bossid);
            int ret_count;
            try (ResultSet rs = ps.executeQuery()) {
                if (rs.next()) {
                    ret_count = rs.getInt(1);
                } else {
                    ret_count = -1;
                }
            }
            ps.close();
            return ret_count;
        } catch (Exception Ex) {
            FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) Ex);
            return -1;
        }
    }

    public int getQianDaoAcLog(String bossid) {
        try (Connection con = BeePool.getConnection()) {
            int ret_count = 0;
            PreparedStatement ps = con.prepareStatement("select count(*) from Aclog where accid = ? and bossid = ? and lastattempt >= DATE_SUB(curdate(),INTERVAL 0 DAY)");
            ps.setInt(1, this.getClient().getAccID());
            ps.setString(2, bossid);
            ResultSet rs = ps.executeQuery();
            if (rs.next()) {
                ret_count = rs.getInt(1);
            } else {
                ret_count = -1;
            }
            rs.close();
            ps.close();
            return ret_count;
        } catch (Exception Wx) {
            FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) Wx);
            return -1;
        }
    }

    public boolean ChrDangerousAcc(String acc) {
        boolean ret = false;
        try (Connection con = BeePool.getConnection();
             PreparedStatement ps = con.prepareStatement("SELECT COUNT(*) FROM dangerousacc WHERE ? LIKE CONCAT(acc, '%')")) {
            ps.setString(1, acc);
            try (ResultSet rs = ps.executeQuery()) {
                rs.next();
                if (rs.getInt(1) > 0) {
                    ret = true;
                }
            }
        } catch (SQLException ex) {
            System.err.println("Error dangerousname " + ex);
            FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) ex);
        }
        return ret;
    }

    public void setChrDangerousAcc(String acc) {
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = con.prepareStatement("INSERT INTO dangerousacc (acc) VALUES (?)");
            ps.setString(1, acc);
            ps.executeUpdate();
            ps.close();
        } catch (SQLException Wx) {
            FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) Wx);
        }
    }

    public long getChangeTime() {
        return this.mapChangeTime;
    }

    public void setChangeTime(boolean changeMap) {
        this.mapChangeTime = System.currentTimeMillis();
        if (changeMap) {
            this.getCheatTracker().resetInMapIimeCount();
        }
    }

    public int getDDJF() {
        return this.getDDJF(this);
    }

    public int getDDJF(MapleCharacter chr) {
        int maxtimes = 10;
        int nowtime = 0;
        int delay = 500;
        boolean error = false;
        int x = 0;
        do {
            ++nowtime;
            try (Connection con = BeePool.getConnection()) {
                Statement stmt = con.createStatement();
                ResultSet rs = stmt.executeQuery("Select DDJF from Accounts Where id = " + chr.getClient().getAccID());
                while (rs.next()) {
                    int debug = -1;
                    try {
                        debug = rs.getInt("DDJF");
                    } catch (Exception ex2) {
                    }
                    if (debug != -1) {
                        x = rs.getInt("DDJF");
                        error = false;
                    } else {
                        error = true;
                    }
                }
                rs.close();
            } catch (SQLException SQL) {
                System.err.println("[getDDJF]无法连接资料库");
                FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) SQL);
            } catch (Exception ex) {
                FilePrinter.printError("MapleCharacter.txt", (Throwable) ex, "getDDJF");
                System.err.println("[getDDJF]" + ex);
                FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) ex);
            }
            if (error) {
                try {
                    Thread.sleep((long) delay);
                } catch (Exception ex) {
                    FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) ex);
                }
            }
        } while (error && nowtime < maxtimes);
        return x;
    }

    public void setDDJF(int x) {
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = con.prepareStatement("Update Accounts set DDJF = ? Where id = ?");
            ps.setInt(1, x);
            ps.setInt(2, this.getClient().getAccID());
            ps.execute();
            ps.close();
        } catch (SQLException ex) {
            System.err.println("[DDJF]无法连接资料库");
            FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) ex);
        } catch (Exception ex2) {
            FilePrinter.printError("MapleCharacter.txt", (Throwable) ex2, "SetDDJFF");
            System.err.println("[setDDJF]" + ex2);
            FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) ex2);
        }
    }

    public boolean canHold() {
        for (int i = 1; i <= 5; ++i) {
            if (this.getInventory(MapleInventoryType.getByType((byte) i)).getNextFreeSlot() <= -1) {
                return false;
            }
        }
        return true;
    }

    public void deleteAcLog(String bossid) {
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = con.prepareStatement("DELETE FROM Aclog WHERE accid = ? and bossid = ?");
            ps.setInt(1, this.getClient().getAccID());
            ps.setString(2, bossid);
            ps.executeUpdate();
            ps.close();
        } catch (SQLException Wx) {
            FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) Wx);
        }
    }

    public int getAcLogD(String bossid) {
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = con.prepareStatement("select count(*) from Aclog where accid = ? and bossid = ? and lastattempt >= DATE_SUB(curdate(),INTERVAL 0 DAY)");
            ps.setInt(1, this.getClient().getAccID());
            ps.setString(2, bossid);
            int ret_count;
            try (ResultSet rs = ps.executeQuery()) {
                if (rs.next()) {
                    ret_count = rs.getInt(1);
                } else {
                    ret_count = -1;
                }
            }
            ps.close();
            return ret_count;
        } catch (SQLException Ex) {
            FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) Ex);
            return -1;
        }
    }

    public int getAclogY(String bossid) {
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = con.prepareStatement("select count(*) from Aclog where accid = ? and bossid = ? and DATE_FORMAT(lastattempt, '%Y%m') = DATE_FORMAT(CURDATE( ), '%Y%m')");
            ps.setInt(1, this.getClient().getAccID());
            ps.setString(2, bossid);
            int ret_count;
            try (ResultSet rs = ps.executeQuery()) {
                if (rs.next()) {
                    ret_count = rs.getInt(1);
                } else {
                    ret_count = -1;
                }
            }
            ps.close();
            return ret_count;
        } catch (SQLException Ex) {
            FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) Ex);
            return -1;
        }
    }

    public int getBossLogAS(String bossid) {
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = con.prepareStatement("select count(*) from bosslog where characterid = ? and bossid = ?");
            ps.setInt(1, this.id);
            ps.setString(2, bossid);
            int ret_count;
            try (ResultSet rs = ps.executeQuery()) {
                if (rs.next()) {
                    ret_count = rs.getInt(1);
                } else {
                    ret_count = -1;
                }
            }
            ps.close();
            return ret_count;
        } catch (SQLException Ex) {
            FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) Ex);
            return -1;
        }
    }

    public int getBossLogC(String bossid) {
        int ret_count = 0;
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = con.prepareStatement("select count(*) from bosslog where characterid = ? and bossid = ?");
            ps.setInt(1, this.id);
            ps.setString(2, bossid);
            ResultSet rs = ps.executeQuery();
            while (rs.next()) {
                ret_count += rs.getInt(1);
            }
            ps.close();
            rs.close();
            return ret_count;
        } catch (SQLException Ex) {
            FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) Ex);
            return -1;
        }
    }

    public int getAcLogC(String bossid) {
        try (Connection con = BeePool.getConnection()) {
            int ret_count = 0;
            PreparedStatement ps = con.prepareStatement("select count(*) from Aclog where accid = ? and bossid = ?");
            ps.setInt(1, this.getClient().getAccID());
            ps.setString(2, bossid);
            ResultSet rs = ps.executeQuery();
            while (rs.next()) {
                ret_count += rs.getInt(1);
            }
            rs.close();
            ps.close();
            return ret_count;
        } catch (SQLException Wx) {
            FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) Wx);
            return -1;
        }
    }

    public int getBossLogD(String bossid) {
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = con.prepareStatement("select count(*) from bosslog where characterid = ? and bossid = ? and lastattempt >= DATE_SUB(curdate(),INTERVAL 0 DAY)");
            ps.setInt(1, this.id);
            ps.setString(2, bossid);
            int ret_count;
            try (ResultSet rs = ps.executeQuery()) {
                if (rs.next()) {
                    ret_count = rs.getInt(1);
                } else {
                    ret_count = -1;
                }
            }
            ps.close();
            return ret_count;
        } catch (SQLException Ex) {
            FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) Ex);
            return -1;
        }
    }

    public int getBossLogY(String bossid) {
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = con.prepareStatement("select count(*) from bosslog where characterid = ? and bossid = ? and DATE_FORMAT(lastattempt, '%Y%m') = DATE_FORMAT(CURDATE( ), '%Y%m')");
            ps.setInt(1, this.id);
            ps.setString(2, bossid);
            int ret_count;
            try (ResultSet rs = ps.executeQuery()) {
                if (rs.next()) {
                    ret_count = rs.getInt(1);
                } else {
                    ret_count = -1;
                }
            }
            ps.close();
            return ret_count;
        } catch (SQLException Ex) {
            FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) Ex);
            return -1;
        }
    }

    public long getMrqdTime() {
        return this.mrqdTime;
    }

    public void setMrqdTime(long r) {
        this.mrqdTime = r;
    }

    public int getStChrLog() {
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = con.prepareStatement("select count(*) from characterid where stlog = ?");
            ps.setInt(1, this.id);
            int ret_count;
            try (ResultSet rs = ps.executeQuery()) {
                if (rs.next()) {
                    ret_count = rs.getInt(1);
                } else {
                    ret_count = -1;
                }
            }
            ps.close();
            return ret_count;
        } catch (SQLException Ex) {
            FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) Ex);
            return -1;
        }
    }

    public String getStChrNameLog(int id) {
        int maxtimes = 10;
        int nowtime = 0;
        int delay = 500;
        boolean error = false;
        int x = 0;
        String name = "";
        do {
            ++nowtime;
            try (Connection con = BeePool.getConnection()) {
                Statement stmt = con.createStatement();
                ResultSet rs = stmt.executeQuery("Select characterid from stlog Where stid = " + id);
                while (rs.next()) {
                    int debug = -1;
                    try {
                        debug = rs.getInt("characterid");
                    } catch (SQLException ex2) {
                    }
                    if (debug != -1) {
                        x = rs.getInt("characterid");
                        name = name + getCharacterNameById(x) + ",";
                        error = false;
                    } else {
                        error = true;
                    }
                }
                rs.close();
            } catch (SQLException SQL) {
                FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) SQL);
            } catch (Exception ex) {
                FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) ex);
            }
            if (error) {
                try {
                    Thread.sleep((long) delay);
                } catch (Exception ex) {
                    FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) ex);
                }
            }
        } while (error && nowtime < maxtimes);
        return name;
    }

    public int getStLog() {
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = con.prepareStatement("select count(*) from stlog where characterid = ?");
            ps.setInt(1, this.id);
            int ret_count;
            try (ResultSet rs = ps.executeQuery()) {
                if (rs.next()) {
                    ret_count = rs.getInt(1);
                } else {
                    ret_count = -1;
                }
            }
            ps.close();
            return ret_count;
        } catch (SQLException Ex) {
            FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) Ex);
            return -1;
        }
    }

    public int getStjfLog(int id) {
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = con.prepareStatement("select count(*) from stjflog where characterid = ?");
            ps.setInt(1, id);
            int ret_count;
            try (ResultSet rs = ps.executeQuery()) {
                if (rs.next()) {
                    ret_count = rs.getInt(1);
                } else {
                    ret_count = -1;
                }
            }
            ps.close();
            return ret_count;
        } catch (SQLException Ex) {
            FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) Ex);
            return -1;
        }
    }

    public int getStLogid(int id) {
        int maxtimes = 10;
        int nowtime = 0;
        int delay = 500;
        boolean error = false;
        int x = 0;
        do {
            ++nowtime;
            try (Connection con = BeePool.getConnection()) {
                Statement stmt = con.createStatement();
                ResultSet rs = stmt.executeQuery("Select stid from stlog Where characterid = " + id);
                while (rs.next()) {
                    int debug = -1;
                    try {
                        debug = rs.getInt("stid");
                    } catch (SQLException ex2) {
                    }
                    if (debug != -1) {
                        x = rs.getInt("stid");
                        error = false;
                    } else {
                        error = true;
                    }
                }
                rs.close();
            } catch (SQLException SQL) {
                FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) SQL);
            } catch (Exception ex) {
                FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) ex);
            }
            if (error) {
                try {
                    Thread.sleep((long) delay);
                } catch (Exception ex) {
                    FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) ex);
                }
            }
        } while (error && nowtime < maxtimes);
        return x;
    }

    public void setStLog(int stid) {
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = con.prepareStatement("insert into stlog (characterid, stid) values (?,?)");
            ps.setInt(1, this.id);
            ps.setInt(2, stid);
            ps.executeUpdate();
            ps.close();
        } catch (SQLException Ex) {
            FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) Ex);
        }
    }

    public void setStjfLog(int id, int stid) {
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = con.prepareStatement("insert into stjflog (characterid, stjf) values (?,?)");
            ps.setInt(1, id);
            ps.setInt(2, stid);
            ps.executeUpdate();
            ps.close();
        } catch (SQLException Ex) {
            FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) Ex);
        }
    }

    public void updateStjfLog(int id, int stid) {
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = con.prepareStatement("Update stjflog SET stjf = ? WHERE characterid = ?");
            ps.setInt(1, stid);
            ps.setInt(2, id);
            ps.executeUpdate();
            ps.close();
        } catch (SQLException Ex) {
            FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) Ex);
        }
    }

    public int getStjf(int id) {
        int maxtimes = 10;
        int nowtime = 0;
        int delay = 500;
        boolean error = false;
        int x = 0;
        do {
            ++nowtime;
            try (Connection con = BeePool.getConnection()) {
                Statement stmt = con.createStatement();
                ResultSet rs = stmt.executeQuery("Select stjf from stjflog Where characterid = " + id);
                while (rs.next()) {
                    int debug = -1;
                    try {
                        debug = rs.getInt("stjf");
                    } catch (SQLException ex2) {
                    }
                    if (debug != -1) {
                        x = rs.getInt("stjf");
                        error = false;
                    } else {
                        error = true;
                    }
                }
                rs.close();
            } catch (SQLException SQL) {
                FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) SQL);
            } catch (Exception ex) {
                FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) ex);
            }
            if (error) {
                try {
                    Thread.sleep((long) delay);
                } catch (Exception ex) {
                    FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) ex);
                }
            }
        } while (error && nowtime < maxtimes);
        return x;
    }

    public int getVip() {
        return this.vip;
    }

    public void setVip(int r) {
        this.vip = r;
    }

    public boolean isVip() {
        return this.getVip() > 0;
    }

    public int getOfflinePoints(MapleCharacter victim) {
        return this.getPoints(victim);
    }

    public int getPoints() {
        return this.getPoints(this);
    }

    public int getPoints(MapleCharacter chr) {
        int maxtimes = 10;
        int nowtime = 0;
        int delay = 500;
        boolean error = false;
        int x = 0;
        do {
            ++nowtime;
            try (Connection con = BeePool.getConnection()) {
                Statement stmt = con.createStatement();
                ResultSet rs = stmt.executeQuery("Select points from Accounts Where id = " + chr.getClient().getAccID());
                while (rs.next()) {
                    int debug = -1;
                    try {
                        debug = rs.getInt("points");
                    } catch (SQLException ex2) {
                    }
                    if (debug != -1) {
                        x = rs.getInt("points");
                        error = false;
                    } else {
                        error = true;
                    }
                }
                rs.close();
            } catch (SQLException SQL) {
                System.err.println("[getPoints]无法连接资料库");
                FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) SQL);
            } catch (Exception ex) {
                System.err.println("[getPoints]" + ex);
                FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) ex);
            }
            if (error) {
                try {
                    Thread.sleep((long) delay);
                } catch (Exception ex) {
                    FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) ex);
                }
            }
        } while (error && nowtime < maxtimes);
        return x;
    }

    public void setPoints(int x) {
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = con.prepareStatement("Update Accounts set points = ? Where id = ?");
            ps.setInt(1, x);
            ps.setInt(2, this.getClient().getAccID());
            ps.execute();
            ps.close();
        } catch (SQLException ex) {
            System.err.println("[Points]无法连接资料库");
            FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) ex);
        } catch (Exception ex2) {
            System.err.println("[setPoints]" + ex2);
            FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) ex2);
        }
    }

    public void gainVip() {
        int rmb = this.getMoneyAll();
        if (rmb >= 2000 && rmb < 4000) {
            this.setVip(1);
        } else if (rmb >= 4000 && rmb < 6000) {
            this.setVip(2);
        } else if (rmb >= 6000 && rmb < 8000) {
            this.setVip(3);
        } else if (rmb >= 8000 && rmb < 10000) {
            this.setVip(4);
        } else if (rmb >= 10000) {
            this.setVip(5);
        }
    }

    public int getMoneyAll() {
        try (Connection con = BeePool.getConnection()) {
            int money = 0;
            PreparedStatement ps = con.prepareStatement("SELECT amount FROM donate WHERE username = ?");
            ps.setString(1, this.getClient().getAccountName());
            ResultSet rs = ps.executeQuery();
            while (rs.next()) {
                money += rs.getInt("amount");
            }
            rs.close();
            ps.close();
            return money;
        } catch (SQLException e) {
            FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) e);
            return -1;
        }
    }

    public void setBuLingZanZu(int bossid) {
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = con.prepareStatement("insert into donate (username, amount, paymentMethod, date) values (?,?,?,?)");
            ps.setString(1, this.getClient().getAccountName());
            ps.setString(2, String.valueOf(bossid));
            ps.setString(3, "补领赞助");
            ps.setString(4, FileoutputUtil.NowTime());
            ps.executeUpdate();
            ps.close();
        } catch (SQLException Wx) {
            FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) Wx);
        }
    }

    public void isSquadPlayerID() {
        if (this.getMapId() == 240060000 || this.getMapId() == 240060100 || this.getMapId() == 240060200) {
            EventManager em = this.getClient().getChannelServer().getEventSM().getEventManager("HorntailBattle");
            EventInstanceManager eim = em.getInstance("HorntailBattle");
            String propsa = eim.getProperty("isSquadPlayerID_" + this.getId());
            if (eim != null && propsa != null && propsa.equals("0")) {
                eim.setProperty("isSquadPlayerID_" + this.getId(), "1");
            }
        }
        if (this.getMapId() == 280030000) {
            EventManager em = this.getClient().getChannelServer().getEventSM().getEventManager("ZakumBattle");
            EventInstanceManager eim = em.getInstance("ZakumBattle");
            String propsa = eim.getProperty("isSquadPlayerID_" + this.getId());
            if (eim != null && propsa != null && propsa.equals("0")) {
                eim.setProperty("isSquadPlayerID_" + this.getId(), "1");
            }
        }
        if (this.getMapId() == 270050100) {
            EventManager em = this.getClient().getChannelServer().getEventSM().getEventManager("PinkBeanBattle");
            EventInstanceManager eim = em.getInstance("PinkBeanBattle");
            String propsa = eim.getProperty("isSquadPlayerID_" + this.getId());
            if (eim != null && propsa != null && propsa.equals("0")) {
                eim.setProperty("isSquadPlayerID_" + this.getId(), "1");
            }
        }
        if (this.getMapId() == 551030200) {
            EventManager em = this.getClient().getChannelServer().getEventSM().getEventManager("ScarTarBattle");
            EventInstanceManager eim = em.getInstance("ScarTarBattle");
            String propsa = eim.getProperty("isSquadPlayerID_" + this.getId());
            if (eim != null && propsa != null && propsa.equals("0")) {
                eim.setProperty("isSquadPlayerID_" + this.getId(), "1");
            }
        }
    }

    public void setCsMod(int mod) {
        this.CsMod = mod;
    }

    public int getCsMod() {
        return this.CsMod;
    }

    public void setFxName(String bossid) {
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = con.prepareStatement("insert into fxlog (bossid, characterid) values (?,?)");
            ps.setString(1, bossid);
            ps.setInt(2, this.id);
            ps.executeUpdate();
            ps.close();
        } catch (Exception Ex) {
            FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) Ex);
        }
    }

    public int getFxName(String bossid) {
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = con.prepareStatement("select count(*) from fxlog where bossid = ?");
            ps.setString(1, bossid);
            int ret_count;
            try (ResultSet rs = ps.executeQuery()) {
                if (rs.next()) {
                    ret_count = rs.getInt(1);
                } else {
                    ret_count = -1;
                }
            }
            ps.close();
            return ret_count;
        } catch (SQLException Ex) {
            FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) Ex);
            return -1;
        }
    }

    public int[] getSavedFaces() {
        return this.savedFaces;
    }

    public void setSavedFace(int sel, int id) {
        this.savedFaces[sel] = id;
    }

    public int getSavedFace(int sel) {
        if (sel < this.savedFaces.length) {
            return this.savedFaces[sel];
        }
        return -1;
    }

    public int[] getSavedHairs() {
        return this.savedHairs;
    }

    public void setSavedHair(int sel, int id) {
        this.savedHairs[sel] = id;
    }

    public int getSavedHair(int sel) {
        if (sel < this.savedHairs.length) {
            return this.savedHairs[sel];
        }
        return -1;
    }

    public void maxSkillsByJob() {
        for (ISkill skil : SkillFactory.getAllSkills()) {
            if (skil.canBeLearnedBy((int) this.job) && skil.getId() >= 1000000) {
                this.changeSkillLevel(skil, skil.getMaxLevel(), skil.getMaxLevel());
            }
        }
    }

    public void LearnSkillsByJob(MapleCharacter c) {
        for (ISkill skil : SkillFactory.getAllSkills()) {
            if (skil.canBeLearnedBy((int) this.job) && Math.floor((double) (skil.getId() / 10000)) == (double) c.getJob()) {
                this.changeSkillLevel(skil, (byte) 0, (byte) 10);
            }
        }
    }

    public int setHuanPaoTask(int item) {
        Map itemMap = this.selectPaoHuanItem();
        if (itemMap == null) {
            this.insertPaoHuanItem(item, 0);
            return item;
        }
        return ((Integer) itemMap.get("itemId")).intValue();
    }

    public void insertPaoHuanItem(int itemId, int times) {
        try (Connection con = BeePool.getConnection()) {
            try (PreparedStatement ps = con.prepareStatement("INSERT INTO `pao_huan` ( `characters_id`, `item_id`, `date`, `times`, `gmt_create`) VALUES ( ?, ?, ?, ?, now())")) {
                ps.setInt(1, this.id);
                ps.setInt(2, itemId);
                ps.setString(3, FileoutputUtil.CurrentReadable_Date());
                ps.setInt(4, times);
                ps.execute();
            }
        } catch (SQLException Ex) {
            throw new RuntimeException();
        }
    }

    public Map<String, Integer> selectPaoHuanItem() {
        try (Connection con = BeePool.getConnection()) {
            try (PreparedStatement ps = con.prepareStatement("SELECT * from pao_huan where characters_id=? and date=?")) {
                ps.setInt(1, this.id);
                ps.setString(2, FileoutputUtil.CurrentReadable_Date());
                ResultSet resultSet = ps.executeQuery();
                if (resultSet.next()) {
                    int itemId = resultSet.getInt("item_id");
                    int times = resultSet.getInt("times");
                    Map<String, Integer> result = (Map<String, Integer>) new HashMap();
                    result.put("itemId", Integer.valueOf(itemId));
                    result.put("times", Integer.valueOf(times));
                    return result;
                }
            }
        } catch (SQLException Ex) {
            throw new RuntimeException();
        }
        return null;
    }

    public void deletePaoHuanItem() {
        try (Connection con = BeePool.getConnection()) {
            try (PreparedStatement ps = con.prepareStatement("delete from pao_huan where characters_id=?")) {
                ps.setInt(1, this.id);
                ps.execute();
            }
        } catch (SQLException Ex) {
            throw new RuntimeException();
        }
    }

    public int setHuanPaoTask2(int item) {
        Map itemMap = this.selectPaoHuanItem2();
        if (itemMap == null) {
            this.insertPaoHuanItem2(item, 0);
            return item;
        }
        return ((Integer) itemMap.get("itemId")).intValue();
    }

    public void insertPaoHuanItem2(int itemId, int times) {
        try (Connection con = BeePool.getConnection()) {
            try (PreparedStatement ps = con.prepareStatement("INSERT INTO `pao_huan2` ( `characters_id`, `item_id`, `date`, `times`, `gmt_create`) VALUES ( ?, ?, ?, ?, now())")) {
                ps.setInt(1, this.id);
                ps.setInt(2, itemId);
                ps.setString(3, FileoutputUtil.CurrentReadable_Date());
                ps.setInt(4, times);
                ps.execute();
            }
        } catch (SQLException Ex) {
            throw new RuntimeException();
        }
    }

    public Map<String, Integer> selectPaoHuanItem2() {
        try (Connection con = BeePool.getConnection()) {
            try (PreparedStatement ps = con.prepareStatement("SELECT * from pao_huan2 where characters_id=? and date=?")) {
                ps.setInt(1, this.id);
                ps.setString(2, FileoutputUtil.CurrentReadable_Date());
                ResultSet resultSet = ps.executeQuery();
                if (resultSet.next()) {
                    int itemId = resultSet.getInt("item_id");
                    int times = resultSet.getInt("times");
                    Map<String, Integer> result = (Map<String, Integer>) new HashMap();
                    result.put("itemId", Integer.valueOf(itemId));
                    result.put("times", Integer.valueOf(times));
                    return result;
                }
            }
        } catch (SQLException Ex) {
            throw new RuntimeException();
        }
        return null;
    }

    public void deletePaoHuanItem2() {
        try (Connection con = BeePool.getConnection()) {
            try (PreparedStatement ps = con.prepareStatement("delete from pao_huan2 where characters_id=?")) {
                ps.setInt(1, this.id);
                ps.execute();
            }
        } catch (SQLException Ex) {
            throw new RuntimeException();
        }
    }

    public byte getProfessionLevel(int id) {
        int ret = this.getSkillLevel(id);
        if (ret <= 0) {
            return 0;
        }
        return (byte) (ret >>> 24 & 0xFF);
    }

    public short getProfessionExp(int id) {
        int ret = this.getSkillLevel(id);
        if (ret <= 0) {
            return 0;
        }
        return (short) (ret & 0xFFFF);
    }

    public int getQianDao(String bossid) {
        return this.getQianDao(this.id, bossid);
    }

    public int getQianDao(int id, String log1) {
        int jf = 0;
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = con.prepareStatement("select * from qiandao where id =? and log = ?");
            ps.setInt(1, id);
            ps.setString(2, log1);
            ResultSet rs = ps.executeQuery();
            if (rs.next()) {
                jf = rs.getInt("sz1");
            } else {
                PreparedStatement psu = con.prepareStatement("insert into qiandao (id,log, sz1) VALUES (?,?, ?)");
                psu.setInt(1, id);
                psu.setString(2, log1);
                psu.setInt(3, 0);
                psu.executeUpdate();
                psu.close();
            }
            rs.close();
            ps.close();
            
        } catch (SQLException ex) {
            System.err.println("onetimelog读取发生错误: " + ex);
        }
        return jf;
    }

    public void setQianDao(int id, String bossid) {
        this.setQianDao(id, bossid, 1);
    }

    public void setQianDao(int id, String log1, int slot) {
        int jf = this.getQianDao(log1);
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = con.prepareStatement("UPDATE qiandao SET sz1 = ? where id = ? AND log = ?");
            ps.setInt(1, jf + slot);
            ps.setInt(2, id);
            ps.setString(3, log1);
            ps.executeUpdate();
            ps.close();
            
        } catch (SQLException ex) {
            System.err.println("qiaodao加减发生错误: " + ex);
        }
    }

    public void setQLQianDao(int id, String bossid) {
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = con.prepareStatement("delete from qiandao where characterid = ? and log = ?");
            ps.setInt(1, id);
            ps.setString(2, bossid);
            ps.executeUpdate();
            ps.close();
        } catch (SQLException ex) {
        }
    }

    public int getGamePoints() {
        try (Connection con = BeePool.getConnection()) {
            int gamePoints = 0;
            PreparedStatement ps = con.prepareStatement("SELECT * FROM accounts_info WHERE accId = ? AND worldId = ?");
            ps.setInt(1, this.getClient().getAccID());
            ps.setInt(2, (int) this.getWorld());
            ResultSet rs = ps.executeQuery();
            if (rs.next()) {
                gamePoints = rs.getInt("gamePoints");
                Timestamp updateTime = rs.getTimestamp("updateTime");
                Calendar sqlcal = Calendar.getInstance();
                if (updateTime != null) {
                    sqlcal.setTimeInMillis(updateTime.getTime());
                }
                if (sqlcal.get(5) + 1 <= Calendar.getInstance().get(5) || sqlcal.get(2) + 1 <= Calendar.getInstance().get(2) || sqlcal.get(1) + 1 <= Calendar.getInstance().get(1)) {
                    gamePoints = 0;
                    PreparedStatement psu = con.prepareStatement("UPDATE accounts_info SET gamePoints = 0, updateTime = CURRENT_TIMESTAMP() WHERE accId = ? AND worldId = ?");
                    psu.setInt(1, this.getClient().getAccID());
                    psu.setInt(2, (int) this.getWorld());
                    psu.executeUpdate();
                    psu.close();
                }
            } else {
                PreparedStatement psu2 = con.prepareStatement("INSERT INTO accounts_info (accId, worldId, gamePoints) VALUES (?, ?, ?)");
                psu2.setInt(1, this.getClient().getAccID());
                psu2.setInt(2, (int) this.getWorld());
                psu2.setInt(3, 0);
                psu2.executeUpdate();
                psu2.close();
            }
            rs.close();
            ps.close();
            
            return gamePoints;
        } catch (SQLException Ex) {
            System.err.println("获取角色帐号的在线时间点出现错误 - 数据库查询失败1" + Ex);
            return -1;
        }
    }

    public int getGamePointsPD() {
        try (Connection con = BeePool.getConnection()) {
            int gamePointsPD = 0;
            PreparedStatement ps = con.prepareStatement("SELECT * FROM accounts_info WHERE accId = ? AND worldId = ?");
            ps.setInt(1, this.getClient().getAccID());
            ps.setInt(2, (int) this.getWorld());
            ResultSet rs = ps.executeQuery();
            if (rs.next()) {
                gamePointsPD = rs.getInt("gamePointspd");
                Timestamp updateTime = rs.getTimestamp("updateTime");
                Calendar sqlcal = Calendar.getInstance();
                if (updateTime != null) {
                    sqlcal.setTimeInMillis(updateTime.getTime());
                }
                if (sqlcal.get(5) + 1 <= Calendar.getInstance().get(5) || sqlcal.get(2) + 1 <= Calendar.getInstance().get(2) || sqlcal.get(1) + 1 <= Calendar.getInstance().get(1)) {
                    gamePointsPD = 0;
                    PreparedStatement psu = con.prepareStatement("UPDATE accounts_info SET gamePointspd = 0, updateTime = CURRENT_TIMESTAMP() WHERE accId = ? AND worldId = ?");
                    psu.setInt(1, this.getClient().getAccID());
                    psu.setInt(2, (int) this.getWorld());
                    psu.executeUpdate();
                    psu.close();
                }
            } else {
                PreparedStatement psu2 = con.prepareStatement("INSERT INTO accounts_info (accId, worldId, gamePointspd) VALUES (?, ?, ?)");
                psu2.setInt(1, this.getClient().getAccID());
                psu2.setInt(2, (int) this.getWorld());
                psu2.setInt(3, 0);
                psu2.executeUpdate();
                psu2.close();
            }
            rs.close();
            ps.close();
            
            return gamePointsPD;
        } catch (SQLException Ex) {
            System.err.println("获取角色帐号的在线时间点出现错误 - 数据库查询失败2" + Ex);
            return -1;
        }
    }

    public void gainGamePoints(int amount) {
        int gamePoints = this.getGamePoints() + amount;
        this.updateGamePoints(gamePoints);
    }

    public void gainGamePointsPD(int amount) {
        int gamePointsPD = this.getGamePointsPD() + amount;
        this.updateGamePointsPD(gamePointsPD);
    }

    public void resetGamePointsPD() {
        this.updateGamePointsPD(0);
    }

    public void updateGamePointsPD(int amount) {
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = con.prepareStatement("UPDATE accounts_info SET gamePointspd = ?, updateTime = CURRENT_TIMESTAMP() WHERE accId = ? AND worldId = ?");
            ps.setInt(1, amount);
            ps.setInt(2, this.getClient().getAccID());
            ps.setInt(3, (int) this.getWorld());
            ps.executeUpdate();
            ps.close();
        } catch (SQLException Ex) {
            System.err.println("更新角色帐号的在线时间出现错误 - 数据库更新失败3." + Ex);
        }
    }

    public void resetGamePoints() {
        this.updateGamePoints(0);
    }

    public void updateGamePoints(int amount) {
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = con.prepareStatement("UPDATE accounts_info SET gamePoints = ?, updateTime = CURRENT_TIMESTAMP() WHERE accId = ? AND worldId = ?");
            ps.setInt(1, amount);
            ps.setInt(2, this.getClient().getAccID());
            ps.setInt(3, (int) this.getWorld());
            ps.executeUpdate();
            ps.close();
        } catch (SQLException Ex) {
            System.err.println("更新角色帐号的在线时间出现错误 - 数据库更新失败4." + Ex);
        }
    }

    public int getGamePointsRQ() {
        try (Connection con = BeePool.getConnection()) {
            int gamePointsRQ = 0;
            PreparedStatement ps = con.prepareStatement("SELECT * FROM accounts_info WHERE accId = ? AND worldId = ?");
            ps.setInt(1, this.getClient().getAccID());
            ps.setInt(2, (int) this.getWorld());
            ResultSet rs = ps.executeQuery();
            if (rs.next()) {
                gamePointsRQ = rs.getInt("gamePointsrq");
                Timestamp updateTime = rs.getTimestamp("updateTime");
                Calendar sqlcal = Calendar.getInstance();
                if (updateTime != null) {
                    sqlcal.setTimeInMillis(updateTime.getTime());
                }
                if (sqlcal.get(5) + 1 <= Calendar.getInstance().get(5) || sqlcal.get(2) + 1 <= Calendar.getInstance().get(2) || sqlcal.get(1) + 1 <= Calendar.getInstance().get(1)) {
                    gamePointsRQ = 0;
                    PreparedStatement psu = con.prepareStatement("UPDATE accounts_info SET gamePointsrq = 0, updateTime = CURRENT_TIMESTAMP() WHERE accId = ? AND worldId = ?");
                    psu.setInt(1, this.getClient().getAccID());
                    psu.setInt(2, (int) this.getWorld());
                    psu.executeUpdate();
                    psu.close();
                }
            } else {
                PreparedStatement psu2 = con.prepareStatement("INSERT INTO accounts_info (accId, worldId, gamePointsrq) VALUES (?, ?, ?)");
                psu2.setInt(1, this.getClient().getAccID());
                psu2.setInt(2, (int) this.getWorld());
                psu2.setInt(3, 0);
                psu2.executeUpdate();
                psu2.close();
            }
            rs.close();
            ps.close();
            
            return gamePointsRQ;
        } catch (SQLException Ex) {
            System.err.println("获取角色帐号的在线时间点出现错误 - 数据库查询失败5" + Ex);
            return -1;
        }
    }

    public void gainGamePointsRQ(int amount) {
        int gamePointsRQ = this.getGamePointsRQ() + amount;
        this.updateGamePointsRQ(gamePointsRQ);
    }

    public void resetGamePointsRQ() {
        this.updateGamePointsRQ(0);
    }

    public void updateGamePointsRQ(int amount) {
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = con.prepareStatement("UPDATE accounts_info SET gamePointsrq = ?, updateTime = CURRENT_TIMESTAMP() WHERE accId = ? AND worldId = ?");
            ps.setInt(1, amount);
            ps.setInt(2, this.getClient().getAccID());
            ps.setInt(3, (int) this.getWorld());
            ps.executeUpdate();
            ps.close();
        } catch (SQLException Ex) {
            System.err.println("更新角色帐号的在线时间出现错误 - 数据库更新失败6." + Ex);
        }
    }

    public int getGamePointsPS() {
        try (Connection con = BeePool.getConnection()) {
            int gamePointsRQ = 0;
            PreparedStatement ps = con.prepareStatement("SELECT * FROM accounts_info WHERE accId = ? AND worldId = ?");
            ps.setInt(1, this.getClient().getAccID());
            ps.setInt(2, (int) this.getWorld());
            ResultSet rs = ps.executeQuery();
            if (rs.next()) {
                gamePointsRQ = rs.getInt("gamePointsps");
                Timestamp updateTime = rs.getTimestamp("updateTime");
                Calendar sqlcal = Calendar.getInstance();
                if (updateTime != null) {
                    sqlcal.setTimeInMillis(updateTime.getTime());
                }
                if (sqlcal.get(5) + 1 <= Calendar.getInstance().get(5) || sqlcal.get(2) + 1 <= Calendar.getInstance().get(2) || sqlcal.get(1) + 1 <= Calendar.getInstance().get(1)) {
                    gamePointsRQ = 0;
                    PreparedStatement psu = con.prepareStatement("UPDATE accounts_info SET gamePointsps = 0, updateTime = CURRENT_TIMESTAMP() WHERE accId = ? AND worldId = ?");
                    psu.setInt(1, this.getClient().getAccID());
                    psu.setInt(2, (int) this.getWorld());
                    psu.executeUpdate();
                    psu.close();
                }
            } else {
                PreparedStatement psu2 = con.prepareStatement("INSERT INTO accounts_info (accId, worldId, gamePointsps) VALUES (?, ?, ?)");
                psu2.setInt(1, this.getClient().getAccID());
                psu2.setInt(2, (int) this.getWorld());
                psu2.setInt(3, 0);
                psu2.executeUpdate();
                psu2.close();
            }
            rs.close();
            ps.close();
            
            return gamePointsRQ;
        } catch (SQLException Ex) {
            System.err.println("获取角色帐号的在线时间点出现错误 - 数据库查询失败7" + Ex);
            return -1;
        }
    }

    public void gainGamePointsPS(int amount) {
        int gamePointsPS = this.getGamePointsPS() + amount;
        this.updateGamePointsPS(gamePointsPS);
    }

    public void resetGamePointsPS() {
        this.updateGamePointsPS(0);
    }

    public void updateGamePointsPS(int amount) {
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = con.prepareStatement("UPDATE accounts_info SET gamePointsps = ?, updateTime = CURRENT_TIMESTAMP() WHERE accId = ? AND worldId = ?");
            ps.setInt(1, amount);
            ps.setInt(2, this.getClient().getAccID());
            ps.setInt(3, (int) this.getWorld());
            ps.executeUpdate();
            ps.close();
        } catch (SQLException Ex) {
            System.err.println("更新角色帐号的在线时间出现错误 - 数据库更新失败8." + Ex);
        }
    }

    public int getSkillzq() {
        return this.skillzq;
    }

    public void gainSkillzq(int gain) {
        this.skillzq += gain;
    }

    public void setSkillzq(int id) {
        this.skillzq = id;
    }

    public static int getQuestKillCount(MapleCharacter chr, int mobid) {
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement pse;
            try (PreparedStatement ps = con.prepareStatement("SELECT queststatusid FROM queststatus WHERE characterid = ?")) {
                ResultSet rse;
                try (ResultSet rs = ps.executeQuery()) {
                    pse = con.prepareStatement("SELECT count FROM queststatusmobs WHERE queststatusid = ?");
                    rse = pse.executeQuery();
                    if (rs.next()) {
                        return rse.getInt("count");
                    }
                }
                rse.close();
            }
            pse.close();
        } catch (SQLException e) {
            System.err.println("getQuestKillCount" + e);
            FileoutputUtil.outputFileError("logs/数据库异常.txt", (Throwable) e);
        }
        return -1;
    }

    public boolean isBuffFrom(MapleBuffStat stat, Skill skill) {
        MapleBuffStatValueHolder mbsvh = (MapleBuffStatValueHolder) this.effects.get(stat);
        return mbsvh != null && mbsvh.effect != null && mbsvh.effect.isSkill() && mbsvh.effect.getSourceId() == skill.getId();
    }

    public int getTrueBuffSource(MapleBuffStat stat) {
        MapleBuffStatValueHolder mbsvh = (MapleBuffStatValueHolder) this.effects.get(stat);
        return (mbsvh == null) ? -1 : (mbsvh.effect.isSkill() ? mbsvh.effect.getSourceId() : (-mbsvh.effect.getSourceId()));
    }

    public int getItemQuantity(int itemid) {
        MapleInventoryType type = GameConstants.getInventoryType(itemid);
        return this.getInventory(type).countById(itemid);
    }

    public void cancelEffectFromBuffStat(MapleBuffStat stat, int from) {
        if (this.effects.get(stat) != null && this.effects.get(stat).cid == from) {
            this.cancelEffect(this.effects.get(stat).effect, false, -1L);
        }
    }

    public void dispelSummons() {
        LinkedList<MapleBuffStatValueHolder> allBuffs = new LinkedList(this.effects.values());
        for (MapleBuffStatValueHolder mbsvh : allBuffs) {
            if (mbsvh.effect.getSummonMovementType() != null) {
                this.cancelEffect(mbsvh.effect, false, mbsvh.startTime);
            }
        }
    }

    public String getJobName(short id) {
        return MapleJob.getName(MapleJob.getById((int) id));
    }

    public void gainFame(int famechange, boolean show) {
        this.fame += (short) famechange;
        this.updateSingleStat(MapleStat.FAME, (int) this.fame);
        if (show && famechange != 0) {
            this.client.sendPacket(MaplePacketCreator.getShowFameGain(famechange));
        }
    }

    public void handleDemonJob(int selection) {
        if (selection == 0) {
            this.changeJob(3101);
        } else if (selection == 1) {
            this.changeJob(3100);
        }
    }

    public void resetSP(int sp) {
        for (int i = 0; i < this.remainingSp.length; ++i) {
            this.remainingSp[i] = sp;
        }
        this.client.getSession().write(MaplePacketCreator.updateSp(this, false));
    }

    public void setGmLevel(byte level) {
        this.gmLevel = level;
    }

    public void dispose(byte level) {
        this.gmLevel = level;
    }

    public void setGM(byte level) {
        this.gmLevel = level;
    }

    public short getSpace(int type) {
        return this.getInventory(MapleInventoryType.getByType((byte) type)).getNumFreeSlot();
    }

    public int getCooldownSize() {
        return this.coolDowns.size();
    }

    public void 击杀野外BOSS特效2() {
        this.map.broadcastMessage(MaplePacketCreator.environmentChange("dojang/end/clear", 3));
    }

    public void 击杀野外BOSS特效() {
    }

    public void giveDebuff(MapleDisease disease, MobSkill skill) {
        this.giveDebuff(disease, skill.getX(), skill.getDuration(), skill.getSkillId(), skill.getSkillLevel());
    }

    public void giveDebuff(MapleDisease disease, int x, long duration, int skillid, int level) {
        List<Pair<MapleDisease, Integer>> debuff = Collections.singletonList(new Pair(disease, Integer.valueOf(x)));
        if (!this.hasDisease(disease) && this.diseases.size() < 2) {
            if (disease != MapleDisease.SEDUCE && disease != MapleDisease.STUN && this.isActiveBuffedValue(2321005)) {
                return;
            }
            this.client.sendPacket(MaplePacketCreator.giveDebuff(debuff, skillid, level, (int) duration));
            this.map.broadcastMessage(this, MaplePacketCreator.giveForeignDebuff(this.id, debuff, skillid, level), false);
            this.diseases.put(disease, new MapleDiseaseValueHolder(disease, System.currentTimeMillis(), duration / 100L * 65L));
        } else {
            this.diseases.put(disease, new MapleDiseaseValueHolder(disease, System.currentTimeMillis(), duration));
        }
    }

    public void setBossLogs(String bossid) {
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = con.prepareStatement("insert into bosslogps (characterid, bossid) values (?,?)");
            ps.setInt(1, this.getClient().getAccID());
            ps.setString(2, bossid);
            ps.executeUpdate();
            ps.close();
        } catch (Exception Ex) {
            FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) Ex);
        }
    }

    public void deleteBossLogps(String bossid) {
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = con.prepareStatement("delete from bosslogps where characterid = ? and bossid = ?");
            ps.setInt(1, this.getClient().getAccID());
            ps.setString(2, bossid);
            ps.executeUpdate();
            ps.close();
        } catch (SQLException ex) {
        }
    }

    public void deleteBossLog(String bossid) {
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = con.prepareStatement("delete from bosslog where characterid = ? and bossid = ?");
            ps.setInt(1, this.id);
            ps.setString(2, bossid);
            ps.executeUpdate();
            ps.close();
        } catch (SQLException ex) {
        }
    }

    public int getBossLogS(String bossid) {
        try (Connection con = BeePool.getConnection()) {
            int ret_count = 0;
            PreparedStatement ps = con.prepareStatement("select count(*) from bosslogps where characterid = ? and bossid = ?");
            ps.setInt(1, this.getClient().getAccID());
            ps.setString(2, bossid);
            ResultSet rs = ps.executeQuery();
            if (rs.next()) {
                ret_count = rs.getInt(1);
            } else {
                ret_count = -1;
            }
            rs.close();
            ps.close();
            return ret_count;
        } catch (Exception Wx) {
            return -1;
        }
    }

    public void setLxExp(int a) {
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = con.prepareStatement("Update characters set exp = ? Where id = ?");
            ps.setInt(1, a);
            ps.setInt(2, this.id);
            ps.executeUpdate();
            ps.close();
        } catch (Exception Ex) {
            FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) Ex);
        }
    }

    public void setLxMeso(int a) {
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = con.prepareStatement("Update characters set meso = ? Where id = ?");
            ps.setInt(1, a);
            ps.setInt(2, this.id);
            ps.executeUpdate();
            ps.close();
        } catch (Exception Ex) {
            FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) Ex);
        }
    }

    public void setMPoints(int a) {
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = con.prepareStatement("Update Accounts set mPoints = ? Where id = ?");
            ps.setInt(1, a);
            ps.setInt(2, this.getClient().getAccID());
            ps.executeUpdate();
            ps.close();
        } catch (Exception Ex) {
            FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) Ex);
        }
    }

    public void setMQoints(int a) {
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = con.prepareStatement("Update Accounts set Acash = ? Where id = ?");
            ps.setInt(1, a);
            ps.setInt(2, this.getClient().getAccID());
            ps.executeUpdate();
            ps.close();
        } catch (Exception Ex) {
            FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) Ex);
        }
    }

    public void updateOfflineTime1() {
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = con.prepareStatement("Update lefttime set lefttime = ? Where accid = ?");
            ps.setLong(1, System.currentTimeMillis());
            ps.setInt(2, this.getClient().getAccID());
            ps.executeUpdate();
            ps.close();
            
        } catch (Exception Ex) {
            FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) Ex);
        }
    }

    public void updateOfflineTime() {
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = con.prepareStatement("Update lefttime set lefttime = ? Where accid = ?");
            ps.setLong(1, System.currentTimeMillis());
            ps.setInt(2, this.getClient().getAccID());
            ps.executeUpdate();
            ps.close();
            
        } catch (Exception Ex) {
            FileoutputUtil.outError("logs/资料库异常.txt", (Throwable) Ex);
        }
    }

    public long getLastOfflineTime() {
        long 离线时间 = 0L;
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = con.prepareStatement("select lefttime from lefttime WHERE accid = ?");
            ps.setInt(1, this.getClient().getAccID());
            ResultSet rs = ps.executeQuery();
            if (rs.next()) {
                离线时间 = rs.getLong("lefttime");
            } else {
                离线时间 = System.currentTimeMillis();
                PreparedStatement psu = con.prepareStatement("insert into lefttime (accid, lefttime) values (?,?)");
                psu.setInt(1, this.getClient().getAccID());
                psu.setLong(2, System.currentTimeMillis());
                psu.executeUpdate();
                psu.close();
            }
            rs.close();
            ps.close();
            return 离线时间;
        } catch (Exception Ex) {
            return -1L;
        }
    }

    public void setNewWorldLevel() {
        Start.世界等级 = getFZ9("世界等级");
    }

    public int getBossLog(String log1, int a) {
        if (a < 1) {
            return this.getBossLog(log1);
        }
        return this.getOneTimeLog(log1);
    }

    public void setBossLog(String log1, int a, int b) {
        if (a < 1) {
            this.setBossLog(log1, b);
        } else {
            this.setOneTimeLog(log1, b);
        }
    }

    public int getBossLog(String log1) {
        int jf = 0;
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = con.prepareStatement("select * from bosslog where id =? and log = ?");
            ps.setInt(1, this.id);
            ps.setString(2, log1);
            ResultSet rs = ps.executeQuery();
            if (rs.next()) {
                jf = rs.getInt("sz1");
            } else {
                PreparedStatement psu = con.prepareStatement("insert into bosslog (id,log, sz1) VALUES (?,?, ?)");
                psu.setInt(1, this.id);
                psu.setString(2, log1);
                psu.setInt(3, 0);
                psu.executeUpdate();
                psu.close();
            }
            rs.close();
            ps.close();
        } catch (SQLException ex) {
            System.err.println("bosslog读取发生错误: " + ex);
        }
        return jf;
    }

    public void setBossLog(String log1) {
        this.setBossLog(log1, 1);
    }

    public void set套装伤害加成(double set) {
        this.套装伤害加成 = set;
    }

    public double get套装伤害加成() {
        return this.套装伤害加成;
    }

    public void setBossLog(String log1, int slot) {
        int jf = this.getBossLog(log1);
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = con.prepareStatement("UPDATE bosslog SET sz1 = ? where id = ? AND log = ?");
            ps.setInt(1, jf + slot);
            ps.setInt(2, this.id);
            ps.setString(3, log1);
            ps.executeUpdate();
            ps.close();
        } catch (SQLException ex) {
            System.err.println("bosslog加减发生错误: " + ex);
        }
    }

    public int getOneTimeLog(String log1) {
        int jf = 0;
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = con.prepareStatement("select * from onetimelog where id =? and log = ?");
            ps.setInt(1, this.id);
            ps.setString(2, log1);
            ResultSet rs = ps.executeQuery();
            if (rs.next()) {
                jf = rs.getInt("sz1");
            } else {
                PreparedStatement psu = con.prepareStatement("insert into onetimelog (id,log, sz1) VALUES (?,?, ?)");
                psu.setInt(1, this.id);
                psu.setString(2, log1);
                psu.setInt(3, 0);
                psu.executeUpdate();
                psu.close();
            }
            rs.close();
            ps.close();
        } catch (SQLException ex) {
            System.err.println("onetimelog读取发生错误: " + ex);
        }
        return jf;
    }

    public void setOneTimeLog(String log1) {
        this.setOneTimeLog(log1, 1);
    }

    public void setOneTimeLog(String log1, int slot) {
        int jf = this.getOneTimeLog(log1);
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = con.prepareStatement("UPDATE onetimelog SET sz1 = ? where id = ? AND log = ?");
            ps.setInt(1, jf + slot);
            ps.setInt(2, this.id);
            ps.setString(3, log1);
            ps.executeUpdate();
            ps.close();
        } catch (SQLException ex) {
            System.err.println("onetimelog加减发生错误: " + ex);
        }
    }

    public void deleteOneTimeLog(String log1) {
        this.deleteOneTimeLog(log1, 1);
    }

    public void deleteOneTimeLog(String log1, int slot) {
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = con.prepareStatement("UPDATE onetimelog SET sz1 = ? where id = ? AND log = ?");
            ps.setInt(1, 0);
            ps.setInt(2, this.id);
            ps.setString(3, log1);
            ps.executeUpdate();
            ps.close();
            
        } catch (SQLException ex) {
            System.err.println("onetimelog加减发生错误: " + ex);
        }
    }

    public String getItemName(int id) {
        MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
        return ii.getName(id);
    }

    public int getzb() {
        return this.getLJJF(this.id);
    }

    public void gainzb(int number) {
        this.setLJJF(this.id, number);
    }

    public int getLJJF(int id) {
        int jf = 0;
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = con.prepareStatement("select * from paymoney where characterid =?");
            ps.setInt(1, id);
            ResultSet rs = ps.executeQuery();
            if (rs.next()) {
                jf = rs.getInt("ljjf");
            } else {
                PreparedStatement psu = con.prepareStatement("insert into paymoney (characterid,syjf,ljjf,kydj) VALUES (?,?,?,?)");
                psu.setInt(1, id);
                psu.setInt(2, 0);
                psu.setInt(3, 0);
                psu.setInt(4, 0);
                psu.executeUpdate();
                psu.close();
            }
            rs.close();
            ps.close();
        } catch (SQLException ex) {
            System.err.println("累计积分读取发生错误: " + ex);
        }
        return jf;
    }

    public int getSYJF(int id) {
        int jf = 0;
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = con.prepareStatement("select * from paymoney where characterid =?");
            ps.setInt(1, id);
            ResultSet rs = ps.executeQuery();
            if (rs.next()) {
                jf = rs.getInt("syjf");
            } else {
                PreparedStatement psu = con.prepareStatement("insert into paymoney (characterid,syjf,ljjf,kydj) VALUES (?,?,?,?)");
                psu.setInt(1, id);
                psu.setInt(2, 0);
                psu.setInt(3, 0);
                psu.setInt(4, 0);
                psu.executeUpdate();
                psu.close();
            }
            ps.close();
            rs.close();
        } catch (SQLException ex) {
            System.err.println("剩余积分读取发生错误: " + ex);
        }
        return jf;
    }

    public int getKYDJ(int id) {
        int jf = 0;
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = con.prepareStatement("select * from paymoney where characterid =?");
            ps.setInt(1, id);
            ResultSet rs = ps.executeQuery();
            if (rs.next()) {
                jf = rs.getInt("kydj");
            } else {
                PreparedStatement psu = con.prepareStatement("insert into paymoney (characterid,syjf,ljjf,kydj) VALUES (?,?,?,?)");
                psu.setInt(1, id);
                psu.setInt(2, 0);
                psu.setInt(3, 0);
                psu.setInt(4, 0);
                psu.executeUpdate();
                psu.close();
            }
            ps.close();
            rs.close();
        } catch (SQLException ex) {
            System.err.println("可用点券读取发生错误: " + ex);
        }
        return jf;
    }

    public int getMRJF(int id) {
        int jf = 0;
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = con.prepareStatement("select * from paymoney1 where characterid =?");
            ps.setInt(1, id);
            ResultSet rs = ps.executeQuery();
            if (rs.next()) {
                jf = rs.getInt("mrjf");
            } else {
                PreparedStatement psu = con.prepareStatement("insert into paymoney1 (characterid,mrjf) VALUES (?,?)");
                psu.setInt(1, id);
                psu.setInt(2, 0);
                psu.executeUpdate();
                psu.close();
            }
            ps.close();
            rs.close();
        } catch (SQLException ex) {
            System.err.println("每日积分读取发生错误: " + ex);
        }
        return jf;
    }

    public void setLJJF(int id, int slot) {
        int jf = this.getLJJF(id);
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = con.prepareStatement("UPDATE paymoney SET ljjf = ? where characterid = ?");
            ps.setInt(1, jf + slot);
            ps.setInt(2, id);
            ps.executeUpdate();
            ps.close();
        } catch (SQLException ex) {
            System.err.println("累计充值加减发生错误: " + ex);
        }
    }

    public void setSYJF(int id, int slot) {
        int jf = this.getSYJF(id);
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = con.prepareStatement("UPDATE paymoney SET syjf = ? where characterid = ?");
            ps.setInt(1, jf + slot);
            ps.setInt(2, id);
            ps.executeUpdate();
            ps.close();
        } catch (SQLException ex) {
            System.err.println("剩余充值加减发生错误: " + ex);
        }
    }

    public void setKYDJ(int id, int slot) {
        int jf = this.getKYDJ(id);
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = con.prepareStatement("UPDATE paymoney SET kydj = ? where characterid = ?");
            ps.setInt(1, jf + slot);
            ps.setInt(2, id);
            ps.executeUpdate();
            ps.close();
        } catch (SQLException ex) {
            System.err.println("可用点券加减发生错误: " + ex);
        }
    }

    public void setMRJF(int id, int slot) {
        int jf = this.getMRJF(id);
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = con.prepareStatement("UPDATE paymoney1 SET mrjf = ? where characterid = ?");
            ps.setInt(1, jf + slot);
            ps.setInt(2, id);
            ps.executeUpdate();
            ps.close();
        } catch (SQLException ex) {
            System.err.println("每日充值加减发生错误: " + ex);
        }
    }

    public int getMountId() {
        for (int i = 0; i < Start.坐骑列表.size(); ++i) {
            if (this.id == ((Integer) (Start.坐骑列表.get(i)).getLeft()).intValue()) {
                return ((Integer) (Start.坐骑列表.get(i)).getRight()).intValue();
            }
        }
        this.初始化坐骑();
        return 0;
    }

    public void setMountId(int cid) {
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = null;
            ps = con.prepareStatement("UPDATE riddingmob SET numb = ? WHERE characterid = ?");
            ps.setInt(1, cid);
            ps.setInt(2, this.id);
            ps.execute();
            ps.close();
        } catch (SQLException ex) {
            System.err.println("更新坐骑发生错误: " + ex);
        }
        Start.坐骑列表.clear();
        Start.GetRidMobTable();
    }

    public void 初始化坐骑() {
        Start.坐骑列表.clear();
        int jf = 0;
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = con.prepareStatement("insert into riddingmob (characterid,numb) VALUES (?,?)");
            ps.setInt(1, this.id);
            ps.setInt(2, 1902000);
            ps.executeUpdate();
            ps.close();
        } catch (SQLException ex) {
            System.err.println("初始化坐骑发生错误: " + ex);
        }
        Start.GetRidMobTable();
    }

    public int getNX() {
        return this.getCSPoints(1);
    }

    public void setQuestAdd(int quest) {
        this.setQuestAddZ(MapleQuest.getInstance(quest), (byte) 2, null);
    }

    public void setQuestAddZ(MapleQuest quest, byte status, String customData) {
        MapleQuestStatus stat = new MapleQuestStatus(quest, (int) status);
        stat.setCustomData(customData);
        this.quests.put(quest, stat);
    }

    public long getLimitBreak() {
        return this.limitBreak;
    }

    public void setLimitBreak(long limitBreak) {
        this.limitBreak = limitBreak;
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = con.prepareStatement("UPDATE characters SET limitBreak = ? WHERE id = ?");
            ps.setLong(1, limitBreak);
            ps.setInt(2, this.getId());
            ps.executeUpdate();
            ps.close();
            
        } catch (SQLException Ex) {
            System.err.println("更新角色破功值错误-ps。" + Ex);
        }
    }

    public int getReinNumber() {
        return this.reinNumber;
    }

    public void setReinNumber(int reinNumber) {
        this.reinNumber = reinNumber;
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = con.prepareStatement("UPDATE characters SET reinNumber = ? WHERE id = ?");
            ps.setLong(1, (long) reinNumber);
            ps.setInt(2, this.getId());
            ps.executeUpdate();
            ps.close();
            
        } catch (SQLException Ex) {
            System.err.println("更新角色破功值错误-ps。" + Ex);
        }
    }

    public int getjyhbh() {
        return this.jyhbh;
    }

    public String ssjyhitem(String beizhu) {
        if (Start.canCheckjyh()) {
            injyhDb();
        }
        StringBuilder fh = new StringBuilder();
        for (int key : Start.jyhshu.keySet()) {
            if (Start.jyhshu.get(Integer.valueOf(key)).getbeizhu().contains(beizhu)) {
                fh.append(key).append("#").append(Start.jyhshu.get(key).getbeizhu()).append(" (").append(Start.jyhshu.get(key).getsl()).append(")@");
            }
        }
        return fh.toString();
    }

    public String ssjyhitema(int lei) {
        if (Start.canCheckjyh()) {
            injyhDb();
        }
        StringBuilder fh = new StringBuilder();
        for (int key : Start.jyhshu.keySet()) {
            if (Start.jyhshu.get(key).inventorytype == lei) {
                fh.append(key).append("#").append(Start.jyhshu.get(key).getbeizhu()).append(" (").append(Start.jyhshu.get(key).getsl()).append(")@");
            }
        }
        return fh.toString();
    }

    public String ssjyhitemb() {
        StringBuilder fh = new StringBuilder();
        try {
            Connection con = BeePool.getConnection();
            PreparedStatement ps = con.prepareStatement("SELECT * FROM jyh where charactersid =" + this.id);
            ResultSet rs = ps.executeQuery();
            while (rs.next()) {
                String lx = "";
                switch (rs.getInt("moneytype")) {
                    case 1 -> {
                        lx = " 点卷";
                    }
                    case 2 -> {
                        lx = " 抵用卷";
                    }
                    case 0 -> {
                        lx = " 金币";
                    }
                    case 3 -> {
                        lx = " 交易币";
                    }
                }
                fh.append(rs.getInt("tid")).append("#").append(rs.getString("beizhu")).append(" * ").append((int) rs.getShort("quantity")).append(" 售价: ").append(rs.getInt("money")).append(lx).append("@");
            }
            rs.close();
            ps.close();
            
            return fh.toString();
        } catch (SQLException ex) {
            System.out.println("读取自身交易行失败");
            return fh.toString();
        }
    }

    public String cxjyhyh() {
        String fh = "";
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = con.prepareStatement("SELECT * FROM jyhyh where characterid =" + this.id);
            ResultSet rs = ps.executeQuery();
            if (rs.next()) {
                fh = fh + "" + rs.getInt("jb") + "#" + rs.getInt("dj") + "#" + rs.getInt("jyb");
            } else if (fh == "") {
                ps = con.prepareStatement("insert into jyhyh (characterid,jb,dj,jyb) values (?,?,?,?)");
                ps.setInt(1, this.id);
                ps.setInt(2, 0);
                ps.setInt(3, 0);
                ps.setInt(4, 0);
                ps.executeUpdate();
                ps.close();
                Start.jyhdq.put(Integer.valueOf(this.id), Boolean.valueOf(true));
            }
            rs.close();
            ps.close();
            
            if (fh != "") {
                Start.jyhdq.put(Integer.valueOf(this.id), Boolean.valueOf(true));
            }
            return fh;
        } catch (SQLException ex) {
            System.out.println("读取自身交易行失败");
            return fh;
        }
    }

    public static void injyhDb() {
        if (!Start.交易行) {
            return;
        }
        Start.jyhItem.clear();
        Start.jyhshu.clear();
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = con.prepareStatement("SELECT * FROM jyh");
            ResultSet rs = ps.executeQuery();
            while (rs.next()) {
                int inventorytype = rs.getInt("inventorytype");
                if (inventorytype == 1) {
                    Equip equip = null;
                    equip = new Equip(rs.getInt("itemid"), (short) 0);
                    equip.setQuantity((short) 1);
                    equip.setOwner(rs.getString("owner"));
                    equip.setExpiration(rs.getLong("expiredate"));
                    equip.setUpgradeSlots(rs.getByte("upgradeslots"));
                    equip.setLevel(rs.getByte("level"));
                    equip.setStr(rs.getShort("str"));
                    equip.setDex(rs.getShort("dex"));
                    equip.setInt(rs.getShort("int"));
                    equip.setLuk(rs.getShort("luk"));
                    equip.setHp(rs.getShort("hp"));
                    equip.setMp(rs.getShort("mp"));
                    equip.setWatk(rs.getShort("watk"));
                    equip.setMatk(rs.getShort("matk"));
                    equip.setWdef(rs.getShort("wdef"));
                    equip.setMdef(rs.getShort("mdef"));
                    equip.setAcc(rs.getShort("acc"));
                    equip.setAvoid(rs.getShort("avoid"));
                    equip.setHands(rs.getShort("hands"));
                    equip.setSpeed(rs.getShort("speed"));
                    equip.setJump(rs.getShort("jump"));
                    equip.setViciousHammer(rs.getByte("ViciousHammer"));
                    equip.setItemEXP(rs.getInt("itemEXP"));
                    equip.setGMLog(rs.getString("GM_Log"));
                    equip.setDurability(rs.getInt("durability"));
                    equip.setEnhance(rs.getByte("enhance"));
                    equip.setPotential1(rs.getShort("potential1"));
                    equip.setPotential2(rs.getShort("potential2"));
                    equip.setPotential3(rs.getShort("potential3"));
                    equip.setHpR(rs.getShort("hpR"));
                    equip.setMpR(rs.getShort("mpR"));
                    equip.setGiftFrom(rs.getString("sender"));
                    equip.setIncSkill(rs.getInt("incSkill"));
                    equip.setPVPDamage(rs.getShort("pvpDamage"));
                    equip.setCharmEXP(rs.getShort("charmEXP"));
                    Start.jyhItem.add(new MaplePlayerShopItem((Item) equip.copy(), (short) 1, rs.getInt("money"), rs.getInt("moneytype"), rs.getInt("tid")));
                    Start.jyhshucc(rs.getInt("itemid"), 1, rs.getString("beizhu"), inventorytype);
                } else {
                    Item item = new Item(rs.getInt("itemid"), rs.getByte("position"), rs.getShort("quantity"));
                    Start.jyhItem.add(new MaplePlayerShopItem((Item) item.copy(), rs.getShort("quantity"), rs.getInt("money"), rs.getInt("moneytype"), rs.getInt("tid")));
                    Start.jyhshucc(rs.getInt("itemid"), 1, rs.getString("beizhu"), inventorytype);
                }
            }
            rs.close();
            ps.close();
            
        } catch (SQLException ex) {
            System.out.println("读取交易行失败" + ex);
        }
    }

    public int getwzcz(int id) {
        int jf = 0;
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = con.prepareStatement("select * from paymoney2 where characterid =?");
            ps.setInt(1, id);
            ResultSet rs = ps.executeQuery();
            if (rs.next()) {
                jf = rs.getInt("jyhhb");
            } else {
                PreparedStatement psu = con.prepareStatement("insert into paymoney2 (characterid,jyhhb) VALUES (?,?)");
                psu.setInt(1, id);
                psu.setInt(2, 0);
                psu.executeUpdate();
                psu.close();
            }
            rs.close();
            ps.close();
            
        } catch (SQLException ex) {
            System.err.println("交易行货币读取发生错误: " + ex);
        }
        return jf;
    }

    public void gainwzcz(int id, int slot) {
        int jf = this.getwzcz(id);
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = con.prepareStatement("UPDATE paymoney2 SET jyhhb = ? where characterid = ?");
            ps.setInt(1, jf + slot);
            ps.setInt(2, id);
            ps.executeUpdate();
            ps.close();
            
        } catch (SQLException ex) {
            System.err.println("交易行货币加减发生错误: " + ex);
        }
    }

    public boolean buyjyhitem(int 编号) {
        return Start.交易行 && Start.buyjyh(this, 编号);
    }

    public boolean canHoldSlots(int slot) {
        for (int i = 1; i <= 5; ++i) {
            if (this.getInventory(MapleInventoryType.getByType((byte) i)).isFull(slot)) {
                return false;
            }
        }
        return true;
    }

    public boolean gainjyhyh(int lei, int characterid, int slot) {
        if (!Start.jyhdq.containsKey(characterid)) {
            try (Connection con = BeePool.getConnection()) {
                PreparedStatement ps = con.prepareStatement("SELECT * FROM jyhyh where characterid =" + characterid);
                ResultSet rs = ps.executeQuery();
                String fh = null;
                while (rs.next()) {
                    fh = fh + "" + rs.getInt("jb") + "#" + rs.getInt("dj") + "#" + rs.getInt("jyb");
                }
                rs.close();
                ps.close();
                
                if (fh == null) {
                    ps = con.prepareStatement("insert into jyhyh (characterid,jb,dj,jyb) values (?,?,?,?)");
                    ps.setInt(1, characterid);
                    ps.setInt(2, 0);
                    ps.setInt(3, 0);
                    ps.setInt(4, 0);
                    ps.executeUpdate();
                    ps.close();
                    Start.jyhdq.put(Integer.valueOf(characterid), Boolean.valueOf(true));
                }
            } catch (SQLException ex) {
                return false;
            }
        }
        if (slot == 0) {
            return false;
        }
        if (lei == 0) {
            try (Connection con3 = BeePool.getConnection()) {
                int cid = characterid;
                PreparedStatement ps2 = con3.prepareStatement("UPDATE jyhyh SET jb =jb+ " + slot + " WHERE characterid = " + cid + "");
                ps2.executeUpdate();
                ps2.close();
                con3.close();
                return true;
            } catch (SQLException ex) {
                return false;
            }
        }
        if (lei == 1) {
            try (Connection con3 = BeePool.getConnection()) {
                int cid = characterid;
                PreparedStatement ps2 = con3.prepareStatement("UPDATE jyhyh SET dj =dj+ " + slot + " WHERE characterid = " + cid + "");
                ps2.executeUpdate();
                ps2.close();
                con3.close();
                return true;
            } catch (SQLException ex) {
                return false;
            }
        }
        if (lei == 3) {
            try (Connection con3 = BeePool.getConnection()) {
                int cid = characterid;
                PreparedStatement ps2 = con3.prepareStatement("UPDATE jyhyh SET jyb =jyb+ " + slot + " WHERE characterid = " + cid + "");
                ps2.executeUpdate();
                ps2.close();
                con3.close();
                return true;
            } catch (SQLException ex) {
                return false;
            }
        }
        return false;
    }

    public void killjyhitem(int id) {
        for (MaplePlayerShopItem itemss : Start.jyhItem) {
            if (itemss.jyhid == id) {
                Start.jyhItem.remove(itemss);
                Start.jyhshucc(itemss.item.getItemId(), -1, ((jyhwpss) Start.jyhshu.get(Integer.valueOf(itemss.item.getItemId()))).getbeizhu(), ((jyhwpss) Start.jyhshu.get(Integer.valueOf(itemss.item.getItemId()))).getinventorytype());
                break;
            }
        }
    }

    public int getOneTimeLogcs(String log1) {
        return this.getOneTimeLog(log1);
    }

    public void gainOneTimeLogcs(String log1, int slot) {
        this.setOneTimeLog(log1, slot);
    }

    public boolean hasBlockedInventory() {
        return !this.isAlive() || this.getTrade() != null || this.getConversation() > 0 || this.getPlayerShop() != null || this.map == null;
    }

    public int getInviteid(int log1) {
        int jf = 0;
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = con.prepareStatement("select * from invsystem where ownid =? ");
            ps.setInt(1, log1);
            ResultSet rs = ps.executeQuery();
            if (rs.next()) {
                jf = rs.getInt("objecid");
            }
            rs.close();
            ps.close();
            
        } catch (SQLException ex) {
            System.err.println("invsystem读取发生错误: " + ex);
        }
        return jf;
    }

    public enum FameStatus {
        OK,
        NOT_TODAY,
        NOT_THIS_MONTH;
    }


    /**
     * @Author cc
     * @Description 师门
     */
    public int getLearnTeacher(int charaid, int tybe) {
        try (Connection con = BeePool.getConnection()) {
            int charid = 0;
            PreparedStatement ps = con.prepareStatement("select * from Learnteacher where characterid = ? ");
            ps.setInt(1, charaid);
            ResultSet rs = ps.executeQuery();
            if (rs.next()) {
                switch (tybe) {
                    case 0 -> charid = rs.getInt("worker");
                    case 1 -> charid = rs.getInt("masterworker");
                }
            }
            rs.close();
            ps.close();
            return charid;
        } catch (Exception Ex) {
            return -1;
        }
    }

    public void setLearnTeacher(int workid) {
        try (Connection con = BeePool.getConnection()) {
            PreparedStatement ps = con.prepareStatement("select * from Learnteacher where  characterid = ?");
            ps.setInt(1, workid);
            ResultSet rs = ps.executeQuery();
            if (rs.next()) {
                PreparedStatement pss = con.prepareStatement("update Learnteacher set masterworker=? where  characterid = ?");
                pss.setInt(1, 3);
                pss.setInt(2, workid);
                pss.execute();
                pss.close();
            } else {
                PreparedStatement psu = con.prepareStatement("insert into Learnteacher (characterid, worker,masterworker) values (?,?,?)");
                psu.setInt(1, workid);
                psu.setInt(2, 0);
                psu.setInt(3, 3);
                psu.executeUpdate();
                psu.close();
            }
            rs.close();
            ps.close();
        } catch (Exception ignored) {
        }
    }


    public List<Integer> getiApprentice(final int charaid) {
        try (Connection con = BeePool.getConnection()) {
            final List<Integer> charid = new ArrayList<Integer>();
            final PreparedStatement ps = con.prepareStatement("select * from Learnteacher where worker = ? ");
            ps.setInt(1, charaid);
            final ResultSet rs = ps.executeQuery();
            while (rs.next()) {
                charid.add(rs.getInt("characterid"));
            }
            rs.close();
            ps.close();
            return charid;
        } catch (Exception Ex) {
            return null;
        }
    }

    public void updateApprentice(int workerid, int apprentid, int tybe) {
        try (Connection con = BeePool.getConnection()) {
            String caozuo = "";
            switch (tybe) {
                case 0 -> {
                    caozuo = "Update Learnteacher set worker = '" + workerid + "' , masterworker = 2 Where characterid = '" + apprentid + "'";
                }
                case 1 -> {
                    caozuo = "Update Learnteacher set worker = 0 , masterworker = 0 Where characterid = '" + apprentid + "'";
                }
                case 2 -> {
                    caozuo = "Update Learnteacher set worker =0 , masterworker = 0 Where characterid = '" + apprentid + "'";
                }
            }
            PreparedStatement ps = con.prepareStatement(caozuo);
            ps.execute();
            ps.close();
        } catch (Exception ignored) {
        }
    }

    public int getSchoolIntegral() {
        return this.schoolIntegral;
    }

    public void gainSchoolIntegral(int gain) {
        this.schoolIntegral += gain;
    }
}
